Database / Mnesia intermediate to advanced Interview questions
Explain the internal working of how Mnesia chooses which replica to read from in a load-balanced cluster?
For a table replicated across multiple nodes, Mnesia tracks a per-table where_to_read
preference — by default, favoring reading from the local node's own copy if it holds one, since a local
read avoids any network round-trip entirely.
flowchart TD
A[Read request for Table] --> B{Does this node hold a local copy?}
B -->|Yes| C[Read directly from local copy - no network round-trip]
B -->|No| D[Route read to another node's replica per where_to_read]
If the local node doesn't hold a copy of that table at all, Mnesia routes the read to whichever remote node
is currently designated to serve it, tracked internally and adjustable via
mnesia:table_info(Table, where_to_read) to inspect, or influenced by sticky lock behavior for
writes. This local-first preference is exactly why replicating a hot, read-heavy table onto every node that
actually queries it can meaningfully cut read latency, compared to a setup where most reads have to cross the
network to reach a node that holds a copy.
Invest now in Acorns!!! 🚀
Join Acorns and get your $5 bonus!
Acorns is a micro-investing app that automatically invests your "spare change" from daily purchases into diversified, expert-built portfolios of ETFs. It is designed for beginners, allowing you to start investing with as little as $5. The service automates saving and investing. Disclosure: I may receive a referral bonus.
Invest now!!! Get Free equity stock (US, UK only)!
Use Robinhood app to invest in stocks. It is safe and secure. Use the Referral link to claim your free stock when you sign up!.
The Robinhood app makes it easy to trade stocks, crypto and more.
Webull! Receive free stock by signing up using the link: Webull signup.
More Related questions...
