sezaru

sezaru

Elixir nodes synchronization and load balancing

Hello there.

I have a question regarding how to handle load balancing and zero downtime in case of server crashes for my specific use case.

First I will explain what my system architecture looks like as show in the image bellow:

So, my Server A consists in a bunch of elixir nodes, one node is the Phoenix node which my clients can make requests.

The Fetcher node is in charge of connecting to third-party endpoints (via rest and websocket) and fetch new data from them. This new data is processed and will be sent to the Notification node.

The Notification node is in charge of sending push notifications to the clients. First the client sends its app token to the Phoenix node and a list of type of notifications he is interested in receiving, next the Phoenix node sends this token and list to the Notification node so it knows to who send the new data received from the Fetcher node when it arrives.

Server A is inside one server hardware right now (due to budget constraints), but this is not good since if this hardware goes down for some reason the whole system goes down too. So I was thinking on how could I duplicate this structure inside another server so if one goes down the other is used, something like this:

Now I have Server A and Server B, if one goes down the other will still (hopefully) be working. Also, both Fetcher Node A and Fetcher Node B would be connected to the same third-party endpoints, so both will receive the same external data.

The issue that I can see with this approach is in the Notification nodes.

The first one is that both of them will be sending notifications to the clients, so the clients will receive duplicated notifications. To fix that I need some way to elect one of the two Notification nodes to be the master and allow only this node to send notifications. Also I need to know if the master node goes down so the slave one can start sending the notifications until the master node goes up again.

The second issue is about synchronization of client tokens and list of desired notifications. Since the load balancer will distribute the client requests between both servers, I need a way to keep data about the client tokens, desired notifications synced between both Notification nodes.

Do you guys have any suggestion of what is the best way to handle these cases in Elixir?

Thanks for the help.

Update:

I just found a library called ra from rabbitmq which implements the Raft concensus algorithm.

Seems like a great possible solution for my case. There is a great talk about it here btw: link

Where Next?

Popular in Questions Top

_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
Tee
can someone please explain to me how Enum.reduce works with maps
New
skosch
To my knowledge, put_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for exa...
New
greenz1
I have a phoenix application from which a user can download multiple(5-6) files of size 1MB. I couldn’t find anything related to sending ...
New
shahryarjb
Hello, I have map which I want to convert it to string like this: the map: %{last_name: "tavakkoli", name: "shahryar"} the string I ne...
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 Postgres...
New
Emily
I have VueJS GUIs with the project generated using Webpack. I have Elixir modules that will need to be used by the VueJS GUIs. I forese...
New
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
JorisKok
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New
earth10
Hi, I’m just starting to build a side-project with Elixir and Phoenix and doing some basic test with Elixir alone. What strikes me is th...
New

Other popular topics Top

AstonJ
Posting this to see if we can make things easier for people to get into Neovim. If you use Neovim and have a favourite distro please let ...
New
chrismccord
As promised, the first release candidate of Phoenix 1.3.0 is out! This release focuses on code generators with improved project structure...
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
Fl4m3Ph03n1x
About me? ( if you have nothing better to do than reading about some random guy in the internet :stuck_out_tongue: ) Hello all, this is ...
New
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New
jay1
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New
grych
Hi folks, Few months ago I have announced the proof-of-concept of the library to manipulate the browsers DOM objects directly from Elixi...
639 52673 488
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
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
PeterCarter
There are pre-rolled solutions for other frameworks that do work. However, Phoenix does not seem to have these. Have people had good expe...
New

Latest on Elixir Forum

Elixir Forum

We're in Beta

About us Mission Statement