thamurath

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

kokolegorille

You might want to use libcluster with swarm, from the same author.

kokolegorille

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

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

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.

Where Next?

Popular in Questions Top

JDanielMartinez
Hi! May someone helps me, please! I have two apps into an umbrella project: the first one is Database, which manages queries, and the se...
New
lessless
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
yawaramin
In the Dialyzer docs ( http://erlang.org/doc/man/dialyzer.html#requesting-or-suppressing-warnings-in-source-files ), there is a way to tu...
New
Kagamiiiii
Student & New to elixir. Nice language. I want to convert a english character, e.g. “a”, which is stored in a variable, to it’s asci...
New
polypush135
As many of you may have realized by now (sorry for all the posts here) I’ve been working on a db problem where I’m trying to aggregate a ...
New
minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
Exadra37
Sometimes I want to check if the input into a function is not a blank string. My first approach: defmodule Example do def do_stuff(s...
New
wernerlaude
In AR this is so simple @articles = current_user.articles How to do in Ecto? def index(conn, _params) do current_user = conn.assig...
New
siddhant3030
Hi, I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New
idi527
I’ve been re-reading swift book again and noticed that multiline strings there don’t have a trailing line break, unlike in elixir iex(2)...
New

Other popular topics Top

senggen
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] 15:22:35.803 [error] gen_event {lager_file_backend...
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
_russellb
I want to try my hand at web scraping. What tools/libraries do I need to use. I’m hoping to turn this into something professional so don’...
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
mgjohns61585
Could someone help me? I'm making my first elixir program, number guessing game. I can't figure out how to convert the user's guess from ...
New
johnnyicon
Hi all, I've just started learning Elixir and Phoenix Framework, so please pardon my n00bness at this stage. I'm trying to use Postg...
New
9mm
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
New
AstonJ
We’ve put together this wiki for Phoenix LiveView - please feel free to add any info you feel is worth including. What is Phoenix LiveV...
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New

We're in Beta

About us Mission Statement