Tech●●●●●Difficulty 4 of 5

How does a database survive a machine catching fire?

The speed of light puts a floor under how fast a copy of your data can be saved at a distance: 67 millionths of a second for just 10 km.

▶ Start the story

A database survives a machine catching fire by never keeping its only copy on that machine. It uses replication: keeping several copies of the data on different machines, so that if one is lost, another takes over. This lets a system carry on when parts fail, which is called , and it also lets users be served from nearby places and the work be spread across machines. A backup is different, because its saved copy stays unchanged for a long time, while replicas are updated constantly.

The common setup is single-leader replication. One database, the leader, handles all the writes and records them in a log, and the changes then travel to the replicas. Replicas mostly answer reads, though they may serve slightly , because there is a delay, called , between a change on the leader and its arrival. If the leader dies, a replica steps up, and ideally users barely notice.

The big choice is when a write counts as done. With synchronous replication, it isn't finished until the remote copy also confirms it, so no data is lost, but every write waits, and distance hurts: the speed of light means even 10 km needs at least 67 millionths of a second for a round trip. With asynchronous replication, a write finishes as soon as the local copy has it. That is much faster, but if the machine dies at the wrong moment, the newest data may be lost. Fast and safe pull in opposite directions.

67 µs

the fastest possible round trip over 10 km, versus about 10 to 20 µs for a local cached write

Quiz me

0/3

  1. 1.How does a replica differ from a backup?
  2. 2.What is the risk of asynchronous replication?
  3. 3.Why does synchronous replication slow down as the copies get farther apart?

Recap

Replication trades speed against safety: synchronous copies lose nothing but wait, asynchronous ones are fast but may lose the latest write.

💡 A trick to remember it · Sync is a signed receipt before you leave; async is dropping the letter in the mailbox and hoping.

Surprising fact · The speed of light alone sets a minimum delay for synchronous copying: 67 microseconds for a 10 km round trip.

Sources (4)

No source, no claim. Every fact in this lesson (15 claims) cites at least one of these.

  1. [1]Replication (computing) · Wikipedia
  2. [2]Eventual consistency · Wikipedia
  3. [3]Dynamo (storage system) · Wikipedia
  4. [4]CAP theorem · Wikipedia
More lessons in 💻 Tech (3) See all tech lessons →

One more light on your map.

Get one lesson like this every day, about the things you love. Free, in two or five minutes.

Get the share card for this lesson ↗