Skip to content
tezvyn:

Multi-Region Databases: Resilience, Latency, and Compliance

Source: cockroachlabs.comMediumHow cards are made

Multi-Region Databases: Resilience, Latency, and Compliance

A multi-region database is a strategy for resilience, low latency, and data compliance. It's used to survive region outages, keep data in-country, and serve reads close to users. The footgun is managing low-level replica placement directly, which is complex.

Why it exists

Deploying a database across multiple geographic regions is done for three main reasons: resilience against large-scale outages, low latency for a global user base, and compliance with data residency laws. The challenge is that configuring replica placement, failover, and query routing to meet these goals is incredibly complex and error-prone if done manually.

The mental model

A multi-region database shifts configuration from imperative commands to declarative intent. Instead of telling the database "put 3 replicas in us-east-1 and 2 in eu-west-1," you declare high-level goals like "this data must survive a region failure" and "this table's data must reside in Europe." The database system then figures out the optimal replica placement and query routing to achieve those goals automatically.

How it works

Modern multi-region systems expose this control through SQL-level abstractions. Three key concepts are: Regions: The system distinguishes between cluster regions (where nodes physically exist) and database regions (the subset you choose to use for a specific database). You designate a primary region, then add others. Survival Goals: You declare the level of failure to tolerate, such as SURVIVE ZONE FAILURE or SURVIVE REGION FAILURE. The system uses this to place voting replicas correctly. For instance, region survival requires at least three database regions to maintain quorum if one fails. Table Locality: You define how data for specific tables is distributed to control where it lives and how it's accessed. For example, a REGIONAL BY TABLE setting homes a table's data in one primary region to optimize for fast local access, while still replicating it elsewhere for survival.

When to use it

Use a multi-region architecture for global applications that need to guarantee high availability even if an entire cloud region goes down. It's also critical for complying with data residency laws like GDPR or for reducing read latency for a user base spread across continents.

When not to use it

If your application serves a geographically concentrated user base and doesn't have uptime requirements that justify the cost and complexity, a single-region setup is simpler. The added network latency for writes across regions can also be a bottleneck for write-heavy workloads that don't require geographic distribution.

One canonical example

A European company uses a multi-region database spanning Germany, France, and Ireland, with a SURVIVE REGION FAILURE goal. Their customers table is set to be regional, pinning German user data to the German region for data domiciling. When a user in Berlin loads their profile, the query is routed to Germany for low latency. If the French region fails, the database continues operating using replicas in Germany and Ireland.

Interview question

Which statement best describes the configuration approach of a modern multi-region database system?

  • a.It prioritizes minimizing write latency by ensuring all data is written to the closest regional replica first.
  • b.It relies on developers to manually route user requests to the correct regional database instance.
  • c.It allows declaring high-level objectives, such as data survival or residency, for the system to implement.Correct
  • d.It requires explicit commands to place a specific number of replicas in each geographic region.
Why?

The card states that a multi-region database shifts configuration from imperative commands to declarative intent, allowing users to declare high-level goals like 'this data must survive a region failure'. Option D describes the complex, manual approach that modern systems aim to abstract away.

Just read this? Test yourself on what you have been reading.

Read the original → cockroachlabs.com

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.

Get it on Google PlayiPhone app coming soon

We are hiring for this. Open roles that interview on databases — each one lists the topics its interview covers.

See open roles