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
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.
tty
In migrating there are 3 things you need to consider:
- process state
- process registered name aka how do other processes still contact it
- 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.
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance








