bsilva

bsilva

Communication between Elixir/Erlang services

Hello!

I want to improve my understanding of what’s possible to do into a clustered application and if I can send message around it in a natural way. And also which are the rules/good practices to consider when you move from standalone to a cluster environment.

For example purposes, let’s say that I have two different services:

Service A - Product service (Product’s attributes e.g: name, sku, manufacturer)
Service B - Pricing service (Stores product id + current price)

Those services were either written on Elixir or Erlang.

1 - Would be ok to add both of them into the same cluster? Is there any known problem or implication? What’s the ‘recommended way’ here?

2 - Could I replace completely the communication between then that happened via http with Erlang messages?

2.1 - If yes, how would it be possible? Is rpc suitable for this?
2.2 - How would load balancing work on that scenario? Should I write it or is it transparent?

Thanks :slight_smile:

Most Liked

lpil

lpil

Creator of Gleam

Hello! Welcome to the forum :slight_smile:

It’s perfectly valid to create a cluster containing nodes with different code loaded on it if you wish. :slight_smile:

Yes, this is definitely an option. If you are happy to always use Erlang based languages then a message based API can work well.

At very high throughput you may want to move from the default single TCP connection for inter-node messages to multiple connections. Depending on the skill-set and knowledge of your team is may be harder to implement than more mainstream HTTP APIs (but you’ll have had to implement much less API boilerplate up until this point).

I would advise against using the rpc module much, it uses a single gen server per node and this creates a big bottleneck. Your API should be regular messages sent to named processes.

You will need to implement load balancing for your message based API. There may be libraries that provide this sort of functionality, depending on what you want to do.

Where Next?

Popular in Questions Top

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
qwerescape
Is there a way to get the call stack or stack trace at any point in the code? Not from exceptions, but an expression that returns how the...
New
albydarned
Hello all! I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
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
chrisalley
ExUnit now has describe blocks which is a welcome addition coming from RSpec. In the docs, it states that nested hierarchies of describe ...
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
JeremM34
Hello, how can I check the Phoenix version ? Thanks !
New
vegabook
I'm brand new to Phoenix and I have stripped one of the demo applications to the bone. I just want to get an svg up on the screen. Here i...
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New

Other popular topics Top

marius95
Hello everyone, I try to use an Javascript Event Handler in my root.html.leex file. Therefore I created a function in the app.js file: ...
New
aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
Darmani72
If I have a post route which an argument: post /my_post_route/:my_param1, MyController.my_post_handler How would get the post params ...
New
TunkShif
This post is an instruction guide to help you setup your Neovim for Elixir development from scratch. It includes general information on h...
274 41454 115
New
chrismccord
Phoenix 1.4.0 released Phoenix 1.4 is out! This release ships with exciting new features, most notably with HTTP2 support, improved deve...
688 30840 112
New
joeerl
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New
chrismccord
This release brings a number of exciting features, including integration with the new Phoenix LiveDashboard and Phoenix LiveView. There h...
New
Qqwy
Original source of discussion: This topic on the Pragmatic Programmers' Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New
jason.o
In the code below, if the create action is not set to accept “extra_key” as an input, it errors out with a message shown above. Is there ...
New
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New

We're in Beta

About us Mission Statement