GuSuku

GuSuku

Migrating actors or processes from one node to another within a cluster

I am new to Elixir and looking to run my distributed application (a state machine) on an elastic cluster. I want to know:

(a) If it is possible to migrate a process from one node to another, without losing the state of the actor or its messages (those in inbox and the one that is being processed).

(b) Are there good resources to follow or actively maintained libraries that I can look up for this purpose?

Some reasons when I would want to migrate could be when there is a severe imbalance in the load across nodes in the cluster (say, a new node got added to the elastic cluster) or when the application gets a notification that a particular node is about to go down.

Most Liked

tristan

tristan

Rebar3 Core Team

I haven’t worked on erleans in a while (the company I developed it at is no more) but would like to again and to create an Elixir example or interface if it makes sense to offer some nicer abstractions when using in Elixir. And I suppose an ecto hookup for persistence would be good to do.

So it isn’t production ready but happy to help if anyone tries it out.

idi527

idi527

:waving_hand:

You might want to check out erleans and/or horde.

tty

tty

In migrating there are 3 things you need to consider:

  1. process state
  2. process registered name aka how do other processes still contact it
  3. messages in queue

Process state
You can place the state into a struct or map and have the new SM start_link with this state this would solve this issue.

Registered name
Either use global or have an internal name/process resolver to ensure current processes can still access the migrated SM.

Message in queue
This is a bit trickier. Before migrating you will have to dequeue the messages into a list and provide it to the new SM.

This is a common trick to always dequeue messages into an ets table and process off the table. This trick is typically uses for high transaction processes or for message reordering.

Where Next?

Popular in Questions Top

tduccuong
Hi, is there any work on GUI with Elixir, that is similar to Electron/Javascript? My idea is to bundle Phoenix and BEAM into a single se...
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
vac
Hi, I’m quite new in Elixir and I’m trying to format a string to a PEM format. I have the certificate value like MIIDBTCCAe2...... and I...
New
nobody
How to bind a phoenix app to a specific ip address? could not find anything about that, nowhere, unfortunately, but for me this is quite...
New
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
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
nobody
Hi! In PHP: $_SERVER[‘SERVER_ADDR’] - in Elixir? Searched the docs for ip address and the web, no good results. Thanks!
New
dblack
I’ve got an issue with an app and I’ve no idea of how to troubleshoot it. I’m hoping someone here might have seen something similar. I p...
New
chensan
I have a User schema with a :from_id field set to type :string: defmodule TweetBot.Repo.Migrations.CreateUsers do use Ecto.Migration ...
New
jononomo
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
New

Other popular topics Top

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
JakeBecker
TL;DR: I’ve just released an implementation of Microsoft’s IDE-independent Language Server Protocol for Elixir. It adds language support ...
1144 53690 245
New
hariharasudhan94
lets say i have a sample like a = 20; b = 10; if (a > b) do {:ok, "a"} end if (a < b) do {:ok, b} end if (a == b) do {:ok, "equa...
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
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
RisingFromAshes
I’ve read in another post that it may be possible with a router helper - but I couldn’t find an appropriate one, and tbh, I’m still just ...
New
dblack
I’ve got an issue with an app and I’ve no idea of how to troubleshoot it. I’m hoping someone here might have seen something similar. I p...
New
klo
Got a question about when to concat vs. prepending items to list then reversing to achieve appending. So i know lists boil down to [1 | ...
New
marick
I had some trouble figuring out how to make many-to-many associations work. Once I got it working, I wrote a blog post. Because I’m a nov...
New
jononomo
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
New

We're in Beta

About us Mission Statement