thamurath
How to create a distributed and loadbalanced system?
I am new to Elixir and was wondering how to deploy a distributed and load balanced system.
I mean:
I have in mind a service based architecture, so to say, where each app offers a service the the system.
There could be any number of nodes, and each of them could execute any number of applications, at least one of them.
I have been reading about libcluster, and seems to be the way to achieve automatic node connection, but:
- How to discover wich apps is running the new connected node?
- How to balance the load between them?
I have read a little bit abouf erlang :pool but I do not figure how to use it…
Any tips or documentation links to read would be very much appreciated.
Most Liked
kokolegorille
You should also check Phoenix Pubsub, as standalone… It includes tools from now obsolete Firenest.
Also I am not sure it is a good idea to apply service based architecture concept to the BEAM, because it does not really work that way. Already one node is composed of multiple “micro services”, as any process could provide a service.
Rainer
Have you thought about using a message broker instead of doing everything by yourself?
For this kind of distributed system I’d use RabbitMQ (which is written in erlang)
ityonemo
There’s something about the way that you posted this suggestion that bugged me. I have only been in prod for a short time, so I don’t really know, but I guess my gut feeling is you shouldn’t cluster everything and spawn up services dynamically inside your erlang cluster, just because you can. Maybe I’ve drunk the cool-aid, but one of the core philosophies behind BEAM systems is to give you the ability to reason about and manipulate failure domains. If you merge everything into a flat service mesh, you will lose that, and potentially lose control if by chance you wind up with a bunch of cpu heavy processes on the left side of the mesh and a bunch of io heavy processes on the right side of the mesh. Also, realistically to do what you want to do, you’ll need to organize your code into a single giant monorepo, which may not be what you want.
I think typically what you should do is group your services into “services which ought to come up and down together”, or “services which need security isolation” and use “non-erlang-distribution” methods to pass information between those services.







