We use analytics cookies.We use cookies to analyze site traffic and improve your experience.
Loading...
System Design Masterclass · Data Replication Distribution
Free preview: the first 2 parts of this 7-part lesson.
Already bought the course? Sign in to read the whole lesson.
this lesson is part of
System Design Masterclass
Unlock this lesson and the 751 other paid lessons
$25 once, by PayPal
See the System Design courseread the rest of this lesson in
System Design Masterclass
Unlock this lesson and the 751 other paid lessons
$25 once, by PayPal
See the System Design coursein Data Replication Distribution
This lesson is part of the full System Design Masterclass. Unlock it along with 769 other lessons for a one-time payment.
One-time payment by card or PayPal
Get Lifetime AccessOne-time payment: UPI, card or netbanking
Get Lifetime Access18 Foundation lessons are free, no payment needed. Try them now
It is easy and good
“It is really nice and good Please join the course”
In 2012, Knight Capital deployed a buggy trading algorithm that executed millions of errant trades in 45 minutes, losing $440 million. But imagine a different nightmare: what if the database recording those trades crashed, and the async replica was 10 seconds behind? You'd have 10 seconds of trades with no record of what happened. Regulators would have a field day.
Financial systems, healthcare records, legal documents. There are domains where "we might lose the last few seconds of data" is not a valid sentence. Synchronous exists for these cases. The write doesn't succeed until at least one replica confirms it has the data. If the primary dies one millisecond later, the replica already has everything.
It's slower. Sometimes significantly slower. But when the alternative is explaining to a banking regulator why customer transactions vanished, the is worth it.
The flow is almost identical to async, with one critical difference at step 3:
That wait in step 4 is everything. It means the write now includes the network round trip to the replica plus the replica's disk write time. If your replica is in the same data center, that adds maybe 1-5ms. If it's across the country, that's 30-70ms. If it's across the ocean, 100-200ms.
The guarantee: At the moment the client gets "success," the data exists on at least two machines. If either one dies, the other has the data. Zero data loss during failover, as long as both machines don't die simultaneously.
The cost: Every write is slower by the replica round-trip time. Under heavy load, this can tank write because the primary is constantly waiting for confirmations.
| Mode | Write Latency | Data Loss on Primary Failure | Write Throughput |
|---|---|---|---|
| Async | 1-5ms (local only) | Possible (lag window) | High |
| Sync | 5-200ms (depends on replica distance) | Zero (if replica is healthy) | Lower |