Reputation: 1479
Are there any open source projects or tutorials that are examples of best practice when it comes to scaling erlang projects to multiple nodes?
For example I want to study a project where I start the server on one machine, and I can scale up the web application by simply connecting more nodes and using net_adm:ping to connect the other machines. As close to that as possible. I know the manning erlang book explores this topic a little.
Upvotes: 3
Views: 344
Reputation: 2544
When it comes to scalibility, there are a lot of methods to achieve it, and Erlang/OTP just provides a set of generic tools and mechanisms to implement them simpler, in a way that you can simply make your Erlang runtime a distributed node which can send messages to processes of other nodes or call their functions.
The mechanisms which Erlang provides are as follows:
The notable projects which uses Erlang/OTP tools and mechanisms to make their product scalable are Riak, RabbitMQ, Ejabberd, CouchDB and some others. Lets talk about Riak and RabbitMQ.
Riak for being a Highly Available NoSQL database was implemented based on Amazon Dynamo Paper which is a cluster of nodes on a ring-like topology. The nodes for being partition tolerant, available and eventual consistent use both replication and partitioning style and it needs lots of inter-node communication. Riak uses the Erlang distribution mechanism for most inter-node communication via its gossip protocol. Riak uses Erlang Port Mapper Daemon for resolving node identifiers to a TCP port on a given machine.
RabbitMQ is a message broker that for achieving reliability of messages and scaling the load and throughput uses replication. This way the queues can optionally be made mirrored across multiple nodes. Each mirrored queue consists of one master and one or more slaves. RabbitMQ uses the distribution tools and mechanisms that Erlang/OTP provides, for example it stores the messages on Mnesia and uses its features for replication the data.
If you are looking for a simple tutorial of how to use basic Erlang distribution mechanism, I suggest to use this one which is a ping pong between two nodes.
Upvotes: 3