Think like a designer / CHAPTER 04
Back-of-the-envelope estimation
Estimate traffic, storage, and bandwidth using explicit assumptions and consistent units.
Builds on Functional and non-functional requirements.
- Calculate average and assumed peak request rates.
- Separate logical storage from replication and indexing.
- Use estimates to choose a design action.
01Choose the question before the arithmetic
A note service must save new notes, keep them for a year and answer reads. Calculate the quantities that change those decisions:
- Count writes to estimate how much saving work arrives each second.
- Count retained bytes to plan storage.
- Count repeated reads to decide whether reusable copies could save work.
- Count attachments separately if a few files are much larger than notes.
Use these exercise assumptions:
- Two million people use the service each day.
- Each creates four notes/day.
- Each note, including required metadata, averages 2 KB.
- Notes are retained for 365 days.
- Busy-period traffic is assumed to be five times the daily average.
State units before calculating. Here 1 KB is 1,000 bytes, 1 GB is one billion bytes and 1 TB is one trillion bytes. Binary units such as mebibytes use a different convention.
Assumptions are not measurements. An average 2 KB record can hide large attachments, and a fivefold peak must be checked against real traffic before provisioning. Keep each input beside its calculation so another engineer can change it.
02Carry one workload through the units
Calculate writes and text storage separately:
- **Daily writes:**2 million users ×4 notes =8 million writes/day.
- **Average rate:**8 million ÷86,400 seconds ≈92.6 writes/second.
- **Planning peak:**92.6 ×5 ≈463 writes/second; rounding to about 465 is reasonable for planning.
- **Daily text:**8 million ×2,000 bytes =16 GB/day.
- **Annual text:**16 GB ×365 =5.84 TB.
- **Three full text copies:**5.84 TB ×3 =17.52 TB before supporting structures and spare space.
A note write may also check ownership, update an index and wait for copies to be saved. Measure that complete operation before converting requests/second into a machine count.
Now calculate an assumed ten reads per write:
- Eight million writes ×10 =80 million reads/day.
- Divide by 86,400 to get about 926 reads/second.
- At 2 KB/read, average body transfer is about 1.85 MB/second before network-format overhead.
Finally, suppose 1% of writes include a 5 MB image:
- Eight million ×1% =80,000 images/day.
- Multiply by 5 MB to obtain 400 GB/day.
- Compare 400 GB of images with 16 GB of note text. The image path carries 25 times as many new bytes.
Plan image transfer and storage separately from small note records. The calculation explains that choice without requiring a complicated identifier or partitioning scheme.
03Check concurrency, headroom, and uncertainty
Start storage planning with application records, then add what the chosen system actually retains:
- Replicas keep additional current copies.
- Indexes add structures used to find records.
- Recovery logs retain changes needed after failures.
- Backups retain earlier recoverable history under their own retention rule.
- Compression may reduce stored bytes; metadata and spare capacity add more.
Do not replace those separate estimates with an unexplained universal multiplier.
Next distinguish arrival rate from simultaneous work. If 500 requests arrive each second and spend 0.2 seconds in the system on average, a stable system has about 500 × 0.2 = 100 requests being handled or waiting. This is average concurrency. Use the same start/end points for both measurements. It does not calculate p99 and does not make an endlessly growing queue stable.
Check one failure using surviving capacity:
- Four machines share 1,200 requests/second, so each receives 300/second while all are healthy.
- Lose one machine without changing demand. Each of three survivors receives 400/second.
- If testing found that a machine meets the latency target only up to 350/second, this fleet cannot safely cover the failure at that load.
Finish with the consequence and next evidence:
- Images dominate bytes, so size their transfer and storage separately.
- A modest write count alone does not prove a need for many database shards.
- Measure the busiest users, record sizes, complete query work and peak shape.
- If an input range gives the same conclusion, use that conclusion and measure the uncertain value next.
Follow the units, then choose the path
Follow the numbered arrows
- 2M users × 4 → Divide by 86,400convert operations to rate
- 2M users × 4 → Text bytesmultiply by note bytes
- 2M users × 4 → Attachment bytesapply attachment fraction
- Text bytes → Physical budgetinclude retained text
- Attachment bytes → Physical budgetinclude retained objects
- Physical budget → Separate byte pathcompare dominant costs
Trace the diagram in words
- Keep requests and bytes separate.
- Calculate the rare large-object workload.
- Use the dominant cost to choose the next design investigation.
DRAW. CALCULATE. EXPLAIN.
Size a bookmark service with attachments
20 minutes · guided practice
Assume 5 million users save 2 bookmarks/day at 1 KB each. One half of one percent include a 4 MB snapshot. Retain data for 365 days and assume a sixfold traffic peak.
- Calculate average and peak writes/second.
- Calculate annual text and daily snapshot bytes.
- Explain which storage decision the numbers support.
Compare the worked solution
- Calculate 5 million ×2 =10 million writes/day. Divide by 86,400 to get about 116/second, then apply the assumed sixfold peak to get about 696/second.
- Text adds 10 million ×1 KB =10 GB/day, or 3.65 TB/year.
- Snapshots number 10 million ×0.5% =50,000/day. At 4 MB each, they add 200 GB/day or 73 TB/year before copies and other storage.
- Plan snapshot transfer and storage separately because its bytes dominate the text.
- Three full text copies require 10.95 TB. The snapshot store needs its own stated failure protection and copy calculation; that text number does not describe it.
The checkboxes record your own assessment. The worked solution gives you a way to check the reasoning.
RETRIEVE BEFORE YOU REVEAL
Keep the important ideas.
Say the answer aloud, then turn the card over.
CARD 01How do I estimate traffic?
- Multiply daily users by operations per user.
- Divide by 86,400 for average operations per second.
- Apply a separately stated peak assumption.
- Measure actual request work before turning the rate into a machine count.
CARD 02What belongs in storage planning?
- Calculate record and attachment bytes.
- Count the actual retained copies.
- Add indexes, logs, backup history, and spare space separately.
A small percentage of large attachments can store more bytes than all text records.
CARD 03How do I check survivor capacity?
- Keep peak demand unchanged after the named failure.
- Divide it across surviving machines.
- Compare with tested capacity at the response-time target.
- Allow for uneven work, retries, and shared dependencies.
CHECK THE REASONING
Can you explain the choice?
Answer every question, then finish for an immediate score and an explanation for each answer. Aim for 80%, then revisit any gaps.
CLOSE THE LOOP
Explain it without the page.
Summarise the mechanism, one trade-off, and one failure mode. Then mark this chapter complete.