Skip to content
StackDecode
System Design
5. Advanced Database ArchitectureAnimated

Multi-Version Concurrency Control (MVCC)

Keep several versions so readers do not block writers.

The idea

Each write creates a new version. Readers see a consistent snapshot while writers proceed.

Watch it work

Press play, pause, or step through. Some animations have settings you can change.

ReaderDatabaseWriterBEGIN (snapshot at t=10)
  • current message
  • earlier
  • failure or attack

The reader starts and sees the database as of time 10.

step:
1/6
from:
Reader
to:
Database
1/6

Time runs downward. Solid arrows are requests, dashed arrows are replies.

Step by step

  1. 1Writer creates a new version
  2. 2Readers keep seeing their snapshot
  3. 3Commit makes the new version visible
  4. 4Old versions are cleaned up

Where it is used

PostgreSQL, MySQL InnoDB.

Watch out for

Old versions need vacuuming.

Related