Mnesia: Load sharing and redundancy

Erlang Questions erlang@REDACTED
Thu Mar 18 15:54:56 CET 2004

In order to have load sharing and redundancy in Mnesia and following the tips that I recolected, I decided to implement a solution with three nodes (one per machine) and fragment the tables in X (X multiple of three) fragments distributed between the three nodes as follows:
Node A - fragments 'ai' and 'bi'
Node B - fragments 'bi' and 'ci'
Node C - fragments 'ci' and 'ai'

With i between 1 and X (this to avoid huge fragments)

I am just to put this mess in service. Does anyone have expirience with an arquitecture like this running stable in field? My laboratory tests were all right, but it is not the same at client side.
Any recomendations before doing that?

A solution with fragments like the one above, assures me load sharing between Mnesia nodes?

Thanks a lot, Carlos.-

Carlos> Hi, I want to implement load sharing without loosing redundancy.
Carlos> Can anyone give me an example on how to fragment and replicate a
Carlos> Mnesia database to have this implemented?  I mean referencing, how
Carlos> many nodes, machines and fragments. And the distribution of them.
Carlos> For example I figure that  this could be a good solution, isn't it?
Carlos> Two nodes in one machine and two other nodes in another machine. Nodes
Carlos> A and B in machine M1, nodes C and D in machine M2.
Carlos> All DB tables fragmented in two fragments one fragment resident at
Carlos> node A, and one fragment at node C (then we use M1 and M2 machines to
Carlos> have load sharing).
Carlos> This implementation replicated as follows: fragments at node A
Carlos> replicated at node D, and fragments at node C replicated at node B
Carlos> (then we have cross replicas - M1 fragments with M2 ones).  See
Carlos> attachment for representation.
Carlos> I would apreciate your answer very much, to have my DB implemented as
Carlos> soon as possible.
Carlos> Thanks, Carlos E. Silva.-

In order to keep things simple, I would suggest that you:

- Only have one node per machine. Why have you choosen to have two
  nodes per machine?

- Avoid addition of new fragments to existing tables while system is
  in full operation. Addition of new fragments is quite expensive as
  it will imply existing records to be rehashed and moved between
  fragments. A plain move of a fragment is cheaper.

- Avoid huge fragments. If you expect large data volumes you should
  distribute it over more fragments than you would do for small data
  volumes. This would give you a better precision in your load
  balancing and lesser disturbance when you move fragments between

- Try to estimate the maximum number of nodes (machines) that you
  that you ever will use in your system. The number of initial
  fragments should always be more than the maximum number of nodes,
  perhaps a factor 5 or 10 more.

- Take a look at the mnesia/examples/bench example.


  If your maximum configuration only is two nodes there are no point
  in using fragmented tables at all, for the purpose of load balancing.

Håkan Mattsson
High Availability Software, DBMS Internals

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the erlang-questions mailing list