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 storyA 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
Quiz me
0/3
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.
Connects to
- 🗳️ How do computers agree on anything when some of them crash?
- 🧩 How do you split a database too big for one machine?
- 🔺 Why can't a system spread across the world be both always consistent and always available?
- 🧰 Why did Amazon and Google build databases without tables?
- 🏦 Why doesn't money vanish when two bank transfers happen at once?
Sources (4)
No source, no claim. Every fact in this lesson (15 claims) cites at least one of these.