gpreston
Mnesia with dynamic node list via fly.io
Hi all, I’m having trouble on the final mile of solving a problem using Mnesia. The use cases details are:
- I have multiple nodes that each track some local in-memory state (for me these are specifically streams, so I will call them that)
- Each node needs to be able to ask a small set of questions about the global state, specifically “what are all the streams that are running?
- The cluster is deployed on fly.io, which auto start/stops machines based on usage.
To accomplish this, Mnesia seemed like a natural choice, being built-in to the BEAM. However, I keep running into the same problem which manifests in a few ways: Mnesia wants to know on start-up which nodes to put a table on.
- the first issue with this is dns_cluster, which fly.io uses by default, discovers nodes after the application is started. I’d think this is fine, because my schema is more or less “stream ID => stream metadata”, and stream IDs are unique (and if there is a conflict, some kind of handling can be defined), so this connect-after-start could simply merge Mnesia tables. This also is the same problem as scaling to another region without wanting to re-deploy the application.
- The next problem is Mnesia tables don’t like to merge. If they were defined with different node lists, one of them essentially has to be deleted while the other is replicated to the new node. I feel like I could program this but it just sounds like a pain to manage, feels like a solution should already exist, and feels like it means a network split is impossible to smoothly recover from. Even if one of the tables is empty, as long as it exists, Mnesia makes a fuss.
So I am wondering:
- Is there a better, simpler solution for my use case that I’m not thinking of?
- If Mnesia can actually work well here, what am I missing about table merging to make it possible?
Thanks for any insight!
Popular in Questions
Hi,
I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
Original source of discussion: This topic on the Pragmatic Programmers’ Functional Web Development with Elixir, OTP, and Phoenix forum.
...
New
To my knowledge, put_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for exa...
New
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
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
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
Other popular topics
Hi folks,
Few months ago I have announced the proof-of-concept of the library to manipulate the browsers DOM objects directly from Elixi...
New
What is the proper way to load a module from a file in to IEX?
In the python world, doing something like this pretty standard:
from ....
New
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
Hi All,
I set a environment variables in dev.exs , like below code.
when i start server, how can i set the ${enable} value?
thanks.
d...
New
Surface is an experimental library built on top of Phoenix LiveView and its new LiveComponent API that aims to provide a more declarative...
New
Hey,
Just curious what are the main benefits of Elixir compared to Clojure?
When is Elixir more useful than Clojure and vice versa?
Th...
New
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
- #elixirconf-us
- #advent-of-code
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #hex
- #security









