Design a global low-latency database
multi-region database tradeoffs.
a distributed store with replicas near users, a tuned consistency level, accepting lag, conflicts, and cross-region cost.
promising low latency, strong consistency, and low cost together.
What's really being asked
This is a systems-design question gauging whether you can balance latency, consistency, and cost across regions instead of hand-waving a magic solution.
The full answer
Users thousands of kilometers from a single database see high latency because of the speed of light, so the data must live near them. Use a globally distributed database. With Cosmos DB you add read-write regions in North America, Europe, and Asia, and the SDK routes each user to the nearest region. With multi-region writes, each region accepts local writes, so write latency is low everywhere, but concurrent edits in different regions can conflict and you must define a conflict-resolution policy such as last-writer-wins or a custom merge. You deliberately choose a consistency level: session consistency gives read-your-own-writes per user cheaply, while bounded staleness caps how stale reads can be. Strong global consistency would force cross-region coordination and destroy the low latency you set out to provide. Spanner is an alternative that offers external consistency using synchronized clocks, trading some write latency for global ordering.
The mistakes people make
Promising low latency, strong consistency, and low cost together; you must give something up. Forgetting conflict resolution under multi-region writes. Ignoring the cost of replicating capacity and cross-region egress. Putting one primary in a single region and claiming it is global.
What usually comes next
How do you resolve write conflicts? How does data residency or GDPR affect placement? What does session versus bounded staleness guarantee? How do you estimate replication lag and cost?
A concrete example
A collaboration app uses Cosmos DB with read-write regions in Virginia, Amsterdam, and Singapore and session consistency. A Singapore user reads and writes against the Singapore replica in single-digit milliseconds and always sees their own edits. A document edited simultaneously in Amsterdam and Singapore triggers last-writer-wins, and you accept higher monthly cost from provisioning throughput in three regions plus cross-region replication traffic.
Interview question
A candidate proposes a global multi-region database with low-latency local writes everywhere and full strong global consistency at minimal cost. What is the flaw?
- a.Adding regions reduces cost, so the cost claim is the only error
- b.Multi-region databases cannot accept writes in more than one region
- c.Replication between regions is always instantaneous, so consistency is never an issue
- d.Strong global consistency requires cross-region coordination, which conflicts with the low local write latency goalCorrect
Why? this is the answer
Strong global consistency forces synchronous cross-region coordination, raising write latency and cost. You cannot get low local latency, strong global consistency, and low cost at once, which is the core tradeoff.
Just read this? Test yourself on what you have been reading.
Read the original → learn.microsoft.com
- #multi-region
- #cosmos-db
- #spanner
- #consistency
- #system-design
You just looked this up. Could you explain it out loud?
That is the part interviews actually test. Tezvyn takes questions like this one and gives you what the interviewer is really checking, the answer that lands, and the mistake that ends the conversation, in the four minutes before your next meeting.
The iPhone app is on the way
We are building it. Until it lands, nothing here is held back from you: every interview card, your saved cards, streaks and the job board all work in Safari, plus hundreds of free practice quizzes of thirty questions each. Sign in and it all carries over to the app the day it arrives.
Want it as an icon? Tap Share at the bottom of Safari, then Add to Home Screen. It opens full screen and the cards you have read stay available offline.
We are hiring for this. Every open role lists the topics its interview covers, so you can prepare for the real thing rather than guessing.
See open roles