Skip to content
Engineering Bible
System Design

System Design on requirements and estimates

Requirements come before boxes and arrows

  • Write what the system does. A URL shortener creates short links and redirects them.
  • Then how well: how many users, how fast, how often it may be down, what may be lost.
  • Those numbers pick the design. 100 users and 100 million need different systems.

A rough estimate is enough to choose a design

  • Aim for the right power of ten, not exact figures. Round hard.
  • A day has 86,400 seconds, so 1 million requests a day is only about 12 a second.
  • Size for the busiest hour, not the average. Traffic comes in peaks.
new links   100M a month       = ~40 writes/s
redirects   100 per link       = ~4,000 reads/s
storage     6B links x 500 B   = ~3 TB in 5 years
short code  7 chars, base 62   = ~3.5 trillion codes
An estimate for a URL shortener. Reads beat writes 100 to 1, so design for reads first.

Memory is fast, disk is slower, the network is slowest

  • A read from memory takes about 100 nanoseconds. An SSD read takes about 16 microseconds.
  • A round trip inside a data center is about 0.5 ms. Across an ocean it is about 150 ms.
  • So keep hot data in memory, and make as few network round trips as you can.
OperationRough timeVersus memory
Read from memory100 ns1x
Random read from SSD16 µs160x
Round trip in a data center0.5 ms5,000x
California to Netherlands and back150 ms1,500,000x
Orders of magnitude from the well-known “latency numbers” list. Exact values vary by hardware.

Judge latency by percentiles, not the average

  • p99 is the time that 99% of requests beat. The slowest 1% are the tail.
  • An average of 100 ms can hide 1% of requests taking 5 seconds.
  • A page that makes 100 calls has about a 63% chance of hitting one of that slowest 1%.

An availability target is a downtime budget

  • 99.9% available (“three nines”) allows about 8.8 hours of downtime a year.
  • 99.99% allows about 53 minutes a year. 99.999% allows about 5 minutes.
  • Each extra nine costs far more, so pick what users need, not 100%.
  • A service level objective (SLO) is that target, written down and measured.

Every hard dependency lowers availability

  • A request that needs 3 parts, each 99.9% available, succeeds about 99.7% of the time.
  • Redundancy goes the other way: two independent 99.9% copies give about 99.9999%.
  • So take dependencies off the request path, or make them optional.
System Design in seven pages1 / 7