Domanda

  1. What strategy does Mnesia use to define which nodes will store replicas of particular table?
  2. Can I force Mnesia to use specific number of replicas for each table? Can this number be changed dynamically?
  3. Are there any sources (besides the source code) with detailed (not just overview) description of Mnesia internal algorithms?
È stato utile?

Soluzione

  1. Manual. You're responsible for specifying what is replicated where.
  2. Yes, as above, manually. This can be changed dynamically.
  3. I'm afraid (though may be wrong) that none besides the source code. In terms of documenation the whole Erlang distribution is hardly the leader in the software world.

Mnesia does not automatically manage the number of replicas of a given table. You are responsible for specifying each node that will store a table replica (hence their number). A replica may be then:

  • stored in memory,
  • stored on disk,
  • stored both in memory and on disk,
  • not stored on that node - in this case the table will be accessible but data will be fetched on demand from some other node(s).

It's possible to reconfigure the replication strategy when the system is running, though to do it dynamically (based on a node-down event for example) you would have to come up with the solution yourself.

The Mnesia system events could be used to discover a situation when a node goes down; given you know what tables were stored on that node you could check the number of their online replicas based on the nodes which were still online and then perform a replication if needed.

I'm not aware of any application/library which already manages this kind of stuff and it seems like a quite an advanced (from my point of view, at least) endeavor to make one.

However, Riak is a database which manages data distribution among it's nodes transparently from the user and is configurable with respect to the options you mentioned. That may be the way to go for you.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top