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 THIS TESTS This is a systems-design question gauging whether you can balance latency, consistency, and cost across regions instead of hand-waving a magic solution.
A GOOD ANSWER COVERS 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.
COMMON WRONG ANSWERS 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.
LIKELY FOLLOW-UPS 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?
ONE 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.
Read the original → learn.microsoft.com
Get five bites like this every day.
Tezvyn delivers a daily feed of 60-second tech bites with quizzes to lock in what you learn.