← Lessons

quiz vs the machine

Platinum1820

System Design

Read Optimized vs Write Optimized

Designing storage to make reads cheap or writes cheap, since one usually costs the other.

6 min read · advanced · beat Platinum to climb

The structural trade

Storage engines arrange data to favor either reads or writes. Making reads cheap usually means doing more work at write time, and making writes cheap usually means doing more work at read time.

Read optimized designs

  • A B tree keeps data sorted in place, so a lookup or range scan is fast.
  • Maintaining that order on every write costs random in place updates, which are slower.
  • Materialized views and precomputed aggregates push work to write time so reads are trivial.

Write optimized designs

  • An LSM tree appends writes to a log and a memory table, turning writes into fast sequential appends.
  • Reads may need to check several layers, and background compaction merges them, paying the cost later.

How to choose

  • A read heavy workload, like a product catalog, favors read optimized structures and aggressive precomputation.
  • A write heavy workload, like metrics ingestion or event logging, favors write optimized structures.

Match the engine to where your work actually concentrates.

Key idea

Read optimized structures do work at write time so reads are cheap while write optimized structures append fast and defer work to read or compaction time.

Check yourself

Answer to earn rating on the learn ladder.

1. Why is an LSM tree write optimized?

2. What cost does a write optimized engine usually pay?