Dashboard
Courses
Problems
Badges
Theme
Sign inStart free
Courses/Foundations of Scale
Lesson 13 of 16

Replication and durability

Keep data safe and available when machines fail.

15 min read

Machines fail, data must not

Disks die, nodes reboot and whole data centres lose power. If your only copy of the data lives on one machine, any of these means downtime at best and permanent data loss at worst.

Replicas

Replication keeps copies of the data on several machines. A primary takes writes and streams them to replicas, which can serve reads and take over if the primary dies.

  • Synchronous replication: no acknowledged write is lost, but writes are slower
  • Asynchronous replication: fast writes, but the last few seconds can be lost on failover
  • Automatic failover promotes a replica when the primary stops responding

Durability before acknowledgement

Never tell a user something is saved until it is stored durably. A chat message, an upload or a notification request should be written to a replicated store or a durable queue before you return success.

RPO and RTO

Recovery point objective (RPO) is how much data you can afford to lose; recovery time objective (RTO) is how long you can be down. They drive your choices: an RPO of zero needs synchronous replication; an RTO of seconds needs automatic failover.

Key takeaways

  • Every stateful component needs at least one replica
  • Acknowledge only after the data is durable
  • State your RPO and RTO explicitly in your design decisions

Sign in to track lessons and earn badges.

Object storage and mediaScaling reads with replicas

Challenge checkpoint

Course: 0/16 lessons · 0/10 challenges0%

Build it on the canvas, pass the review (70+) and mark it complete to count it toward the course badge.

  1. 7/10Design a Photo Sharing AppCapstone: durable photo storage, CDN delivery, background thumbnails and a replicated metadata store in one design.MAJORMedium
All 10 challenges →