Real-World Case Studies: Database Replication

✅ Source-checked. Each deep dive names its source, and we kept only what that source says. Found an error, or something the source doesn't support? Report it on the tracking issue.

Two opposite designs: Google Spanner replicates every write synchronously through a Paxos leader, while Amazon's Dynamo and Apache Cassandra let any replica accept writes and reconcile later.


đŸĸ Deep Dive 1: Google Spanner, Synchronous Replication with Paxos

Sources: Spanner: Google's Globally-Distributed Database (Corbett et al., OSDI 2012); Google Cloud, Spanner replication. Everything in this section comes from those.


🛒 Deep Dive 2: Amazon Dynamo and Apache Cassandra, Leaderless Replication

Sources: Werner Vogels, "Amazon's Dynamo" (October 2007, introducing DeCandia et al., SOSP 2007); Apache Cassandra docs, Dynamo architecture. Everything in this section comes from those.

Dynamo is "internal technology developed at Amazon to address the need for an incrementally scalable, highly-available key-value storage system". It aims to be "always writeable": for example, the shopping cart "must allow customers to add and remove items from their shopping cart even amidst network and server failures".

Cassandra borrows the same ideas:

â„šī¸ An earlier version of this page described Netflix's specific Cassandra regions, "<4ms" writes and custom NTP daemons, and gave Spanner a five-nines SLA across "5 continents". We couldn't find sources we could read for those details, so we described the general Dynamo and Cassandra mechanics from their own documentation instead.


âš–ī¸ Side by Side

Spanner Dynamo / Cassandra
Who accepts a write The Paxos leader for that tablet Any replica the coordinator reaches
When a write is acknowledged When a Paxos majority has it When W replicas (or a local quorum) have it
Conflicts Prevented: writes are ordered by the leader Expected: resolved by vector clocks (Dynamo) or last-write-wins timestamps (Cassandra)
Main cost Write latency includes a round trip to a majority Reads can see stale data unless R + W > N

đŸŽ¯ System Design Interview Takeaways

  1. State the quorum rule. With N replicas, choosing R + W > N makes every read set overlap every write set. Cassandra's docs express the same rule as W + R > RF.
  2. Synchronous vs. asynchronous is a latency vs. data-loss trade-off. Waiting for a majority, as Spanner does, costs a round trip but survives losing a minority. Acknowledging locally is faster but can lose recent writes.
  3. Last-write-wins needs good clocks. If you propose it, mention clock synchronization, as Cassandra's docs do.