stackbook.io
🔍
← Back to Syllabus
Day 3Level 1 — Vocabulary

Latency, Throughput, and Back-of-Envelope Estimation

Learn: 35 minMap: 25 minDesign: 40 min

Core Concepts (5)

  • 1.Latency is time per request; throughput is requests per unit time
  • 2.Percentiles describe real experience better than averages
  • 3.Rough estimates are enough to rule designs in or out
  • 4.Know a few orders of magnitude by heart
  • 5.Peak load, not average load, sizes the system

Map to Your Experience

Think of a time a page felt slow. Was it one slow request, or too many requests at once? How would you tell?

Design Brief: Size a Messaging Service

Learn

Two numbers describe most performance conversations. Latency is how long one request takes, measured in milliseconds. Throughput is how many requests the system handles per second. They are related but different: a highway can have high throughput and still take an hour to cross.

Averages hide pain. If 99 requests take 100 milliseconds and one takes ten seconds, the average looks fine, but one user in a hundred is miserable. That is why teams quote percentiles. The p50 is the median experience, the p95 is what one in twenty users sees, and the p99 is the tail. Targets are normally set on p95 or p99.

Back-of-envelope estimation means working out rough size with simple arithmetic. The goal is not accuracy, it is to find out whether you need one server or one hundred, one gigabyte or one petabyte. Being off by a factor of two rarely changes the design; being off by a factor of a thousand always does.

Memorise a few orders of magnitude. Reading from memory takes about 100 nanoseconds. A round trip inside one data centre takes around half a millisecond. A disk seek takes several milliseconds. A trip across continents takes over 100 milliseconds. A day has about 100 thousand seconds, which is a handy rounding for conversions.

A worked example: one million daily users each send 20 messages. That is 20 million messages per day, or roughly 200 per second on average. Traffic is bursty, so assume peak is five times average: about 1,000 per second. If each message is 200 bytes, a day stores 4 gigabytes and a year about 1.5 terabytes. Now you know a single modest database can hold the data, while the peak rate deserves attention.

Always write down the assumptions. When someone challenges the answer, you change an assumption and recompute rather than argue.

Map

Estimate the daily storage for a video site where 100 thousand users upload one two-minute clip a day, assuming 20 megabytes per clip. Convert the result into storage per year and say which unit you would quote.

Design

Size a chat service with one million daily active users. Produce average and peak requests per second, yearly storage, and the bandwidth at peak. List your assumptions in a table, then state one design implication that follows from your numbers, such as whether one database node is plausible.

Requirements

  • •Estimate requests per second at average and peak
  • •Estimate storage per year
  • •State every assumption

Constraints

  • •Use powers of ten
  • •No tools beyond a calculator

Must Cover

qps-estimatestorage-estimateassumptions

Trade-off Axis

precision vs speed of decision

Referenced Patterns

Competencies Advanced

requirements constraints → L1economics evolution → L1

Ready to Design?

Open this day in the Design Studio. The studio follows this track: its days, concepts, patterns and trade-offs are loaded, and you keep one design across the whole track.

Open in Studio →