fireproofsocks

fireproofsocks

Simple examples of distributed systems in Elixir?

I’m working to increase my understanding of how to build distributed systems as a way to leverage concurrency. I understand this is a broad topic, but I’m wondering if anyone has some examples of how to structure “work” across multiple nodes or multiple apps.

I admit I am not even sure I follow how things happen when you deploy a single app across multiple nodes (e.g. 1 app deployed to 2 EC2 instances)… that means there are 2 instances of the Erlang VM running. How is work delegated? E.g. if it’s a Phoenix app, does a multiple-server deployment assume that a load balancer is figuring out the “division of labor” and routing requests to different nodes? And does this assume that each node more or less has no awareness of the other nodes?

Or how about when you want to process a stream of inputs (e.g. using Task.async_stream/3)… do you have any way of routing the processing to different nodes? For this to work, wouldn’t each node need to know about the other nodes? Locally, this happens by specifying --sname and --remsh options when starting the app, e.g. something like

iex --sname app1@localhost -S mix
iex --sname app2 --remsh app1@localhost

What are good questions to ask when deciding how to break up work across multiple nodes/apps?

Most Liked

viniciusmuller

viniciusmuller

Hey, have you checked the “Introduction to Mix” guide in the official documentation?
Although the name can be a bit misleading, this is the description of the guide:

In this guide, we will build a complete Elixir application, with its own supervision tree, configuration, tests, and more.

The application works as a distributed key-value store. We are going to organize key-value pairs into buckets and distribute those buckets across multiple nodes. We will also build a simple client that allows us to connect to any of those nodes and send requests

I think it might be helpful, it covers how nodes connect to each other using the configurations and shows some example of running code in a remote node and distributing work across nodes via sharding.

Overall the erlang runtime does no magic to help you and you still need to build your own mechanisms of distribution and load balancing in your application, but it provides all the building blocks you’ll need to do so.

apsori

apsori

I really need to get a copy of this book :slight_smile:

Where Next?

Popular in Discussions Top

joeerl
I’m playing with Elixir - It’s fun. I think @rvirding does give Elixir courses these days. Re: files and database - when I given Erlang ...
New
chulkilee
Here are the list of HTTP client libraries/wrappers, and some thoughts on HTTP client in general. I’d like to hear from others how they w...
New
Nvim
Anybody knows a comprehensive comparison of Django and Phoenix, thanks for the help. Where are they similar? Where do they differ the m...
New
owaisqayum
I have a sample string sentence = "Hello, world ... 123 *** ^%&*())^% %%:>" From this string, I want to only keep the integers, ...
New
saif
Hello everyone, Long time lurker first time poster here. I’ve recently begun working on Elixir full-time again! :raised_hands: It’s been...
New
crispinb
On reading dhh’s latest The One Person Framework it strikes me that Phoenix with LiveView is already pretty much this. However, never hav...
New
arcanemachine
https://nitter.net/josevalim/status/1744395345872683471 https://twitter.com/josevalim/status/1744395345872683471
New

Other popular topics Top

stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
axelson
This post is a wiki (feel free to hit the edit button near the bottom right of this post to add your own changes!) This post collects co...
239 49084 226
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
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
Patoshizzle
After calling mix ecto.create I get this error: 17:00:32.162 [error] GenServer #PID<0.412.0> terminating ** (Postgrex.Error) FATAL...
New
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

We're in Beta

About us Mission Statement