← Lessons

quiz vs the machine

Gold1380

System Design

Immutable Data and Snapshots

Capturing a consistent point in time view without copying everything.

5 min read · core · beat Gold to climb

Data that never changes

Immutable data is written once and never modified. To change a value you write a new version and leave the old one intact. This makes reasoning simple, enables safe sharing without locks, and lets the system keep history.

What a snapshot is

A snapshot is a consistent, read only view of data as it existed at one instant. Because the underlying data is immutable, a snapshot is just a reference to the set of versions that were current at that moment.

Copy on write

Naively copying all data for each snapshot would be wasteful. Instead systems use copy on write: the snapshot shares existing blocks with the live data. Only when a block is later modified does the system write a new copy, leaving the snapshot pointing at the original. Snapshots therefore cost almost nothing to create.

What snapshots buy you

  • Backups taken from a stable view while writes continue.
  • Rollback to a known good state after a bad change.
  • Reproducibility because a reader can pin a version.

Key idea

Immutability plus copy on write let a system create cheap point in time snapshots that share unchanged blocks, giving stable backups and rollback without duplicating all the data.

Check yourself

Answer to earn rating on the learn ladder.

1. How does copy on write make snapshots cheap to create?

2. What is a key benefit of immutable data?