Course contentsShow
← Databases & SQL
Lesson 1408 of 1,95313. Specialized Data StorageFree lesson

Multi-Region Replication Models

Synchronize global data sets while minimizing inter-region latency.

In this lesson, you will learn how to synchronize global data sets across multiple geographical regions to maintain performance without sacrificing availability.

When your users are scattered across continents, relying on a single database region introduces unacceptable inter-region latency. If a user in Tokyo requests data stored in a data center in Virginia, the round-trip time (RTT) for the speed of light alone creates a "slow" experience. To solve this, we employ Multi-Region Replication Models.

Active-Passive Replication

In an Active-Passive setup, all writes are sent to a "Primary" region, which then asynchronously replicates data to "Read-only" regions globally. This is excellent for low-latency local reads. However, because replication is asynchronous, you face the challenge of stale reads. A user might update their profile in the Primary region, but if they immediately navigate to a page served by a local Read-only region, they might see the old version of their data.

Multi-Master (Active-Active) Replication

To minimize write latency, we use Multi-Master replication, where every region is capable of accepting both reads and writes. Data is synchronized across all regions in the background.

-- Conceptual example of a regional write strategy
-- Each record includes a source region and a timestamp
INSERT INTO user_sessions (session_id, user_id, region_origin, last_updated)
VALUES ('abc-123', 99, 'US-EAST', '2023-10-27 10:00:00 UTC');

The core challenge here is conflict resolution. If the same record is modified simultaneously in two different regions, the database must decide which version wins. Strategies like "Last Write Wins" (using high-precision timestamps) or Vector Clocks are often used to ensure all regions eventually converge to the same state.

By distributing the data geographically, we move the "source of truth" closer to the user. While this introduces complexity regarding consistency levels, it is the most effective way to ensure that an application remains responsive regardless of where the user is located. By choosing the right replication model—Active-Passive for read-heavy global apps or Multi-Active for distributed write workloads—you balance the trade-off between strict global consistency and local performance.

Key Takeaway: Multi-Region replication minimizes latency by placing data geographically closer to the user, requiring a trade-off between the speed of local writes and the complexity of resolving global data conflicts.