CodingNodes Space play · ←→ step · R restart

The problem

Sooner or later an interviewer stops asking about components and asks the only quantitative question in the room: how big is this thing? Envelope estimation is the craft of answering with arithmetic you can hold in your head — users become queries per second, queries become bytes, bytes become servers, caches and bills.

The good news is that almost every estimate leans on three small ladders that fit in memory. A ladder of units, from one photo to a multi-petabyte archive. A ladder of operation costs, from a cache hit to a round trip across an ocean. And a ladder of availability nines, from "pretty reliable" to "essentially never dark".

This chapter builds all three ladders, then runs a complete worked example — a fictional photo-sharing app with 200 million registered users — from raw population down to traffic rates, daily storage and a five-year archive, exactly the way you would walk it on a whiteboard.

Requirements

Functional — what it must do

  • Turn a population of users into traffic: average and peak rates per second, for both writes and reads.
  • Turn usage into bytes: per-item sizes, the share that carries media, and a retention horizon measured in petabytes.
  • Judge every design idea against those numbers — server counts, cache sizes and storage tiers all fall out of the same arithmetic.
  • Keep the work auditable: rounded inputs, labelled units, and assumptions written down where the reader can check them.

Non-functional — how well it must do it

  • Speed: a full envelope fits in five to ten minutes of an interview — if the arithmetic takes longer, the rounding is wrong.
  • Accuracy: landing within about 10% is plenty; chasing exact digits spends the clock for no design insight.
  • Traceability: every figure must trace back to a stated assumption, so the reader can re-derive or challenge it.
  • Reusability: the same three ladders — units, operation costs, nines — size nearly any system you will be handed.

Scale — how much it must take

  • Worked example carried through the whole chapter: 200 M registered users, 100 M daily active, ~2,300 writes/s on average and ~40 TB of new media every day.

Assumptions — the numbers this design is sized for

A rate limit means nothing without a scale. These are the figures every later part relies on: how much traffic arrives, how much work the limiter has to do per second, and how much latency and memory it may spend doing it.

Registered users
200 million
The population the whole funnel starts from; every later number is a slice of this one.
Daily active share
50%
Half log in on a typical day: 100 M daily active users.
Posting rate
2 posts / user / day
100 M users × 2 posts = 200 M new posts every day.
Media share
20% · 1 MB photo
One post in five carries a single 1 MB photo: 40 M photos, which is 40 TB per day.
Text per post
≈ 264 B
A 64-byte id plus roughly 200 bytes of text: about 53 GB per day — noise next to the media.
Reading intensity
20 views / user / day
100 M users × 20 views = 2 billion reads a day, about 23,000 per second on average.
Peak factors
writes ×2 · reads ×3
Traffic is not flat across the day; the busy hours set ~5,000 peak writes/s and ~70,000 peak reads/s.
Retention
5 years
Media is kept for five years: roughly 15 PB per year, about 73 PB in total — call it 75.

Takeaways

Part 1

The unit ladder

Every estimate starts from bytes. Six rungs, each about a thousand times the last, carry you from one photo to the whole archive.

  1. 1
    Bits to bytes

    Everything downstream is counted in bytes. One typed letter costs a single byte, and a short text post weighs about a kilobyte.

  2. 2
    The megabyte

    The megabyte is this chapter's workhorse unit: one photo in our app weighs exactly 1 MB, and that number drives the whole storage estimate later.

  3. 3
    The gigabyte

    A gigabyte is a thousand photos — roughly one user's photo output for a couple of years at our posting rate.

  4. 4
    The terabyte

    A terabyte is a million photos. This is where our app actually lives day to day: 20% of 200 M posts carry one 1 MB photo, so every single day adds 40 TB of media.

  5. 5
    The petabyte

    A petabyte is a billion photos — rung territory for whole platforms, not single machines. Our five-year archive lands here, at roughly 75 PB.

Part 2

The latency ladder

The second ladder ranks what computers actually wait for. It decides where data can live and how far it is allowed to travel.

  1. 1
    Five costs to memorize

    Five rounded numbers cover almost every latency argument: a cache hit near the CPU, a walk to main memory, a random read on an SSD, a mechanical disk seek, and a packet crossing an ocean and back.

  2. 2
    Cache to memory

    Leaving the chip for main memory costs a factor of 100: what took a nanosecond by the CPU takes a hundred nanoseconds from RAM. Still astonishingly fast.

  3. 3
    Memory to SSD

    Swap memory for a flash drive and each random read is another 200 times slower: 20 microseconds. Fast for storage, but no longer 'free' the way RAM feels.

  4. 4
    SSD to spinning disk

    A mechanical seek waits for an arm to physically swing: about 10 ms, another 500-fold step down. Disk seeks are the classic silent killer of database latency.

  5. 5
    Disk to another continent

    One packet to a datacenter on another continent and back costs about 150 ms — fifteen disk seeks, or a hundred million cache hits. Geography is a latency budget.

  6. 6
    Rescale it to human time

    The trick that makes the ladder stick: pretend a cache hit takes one second. Memory is then a two-minute errand, an SSD read five hours, a disk seek four months, and one ocean round trip almost five years.

Part 3

Availability nines

Reliability is quoted in nines, and every extra nine buys far less downtime than the one before. The table turns each nine into hours you can feel.

  1. 1
    Two nines

    99% sounds excellent until you do the division: it is 7.3 dark hours every month — a full working day of outage, every month.

  2. 2
    Three nines

    One more nine cuts the pain tenfold: 43.8 minutes a month, 8.76 hours a year. This is where most serious consumer services live.

  3. 3
    Four nines

    Four nines allow 4.38 minutes a month — 52.6 minutes over a whole year. Getting there is no longer just good code; it is redundancy, automation and on-call discipline.

  4. 4
    What each nine costs

    Each extra nine is bought, not coded: two nines take care, three take a designed rollout, four take redundancy money, and five take a budget most teams will never see. Quote the nines your product can afford.

Part 4

From users to queries

The first worked number of any design: how much traffic the product must absorb, on average and at peak, for writes and for reads.

  1. 1
    Population to daily active

    Start from the registered population: 200 million accounts. Half of them show up on a typical day, which gives 100 million daily active users.

  2. 2
    Users to posts

    Each daily user writes two posts a day, so the platform receives 200 million new posts every 24 hours.

  3. 3
    The day is not flat

    Before dividing by 86,400 seconds, look at the shape of the day across those very seconds: the busy evening block carries roughly four times the quiet night hours. That skew is why a peak factor exists at all.

  4. 4
    Posts to a write rate

    Spread 200 M posts across the day's 86,400 seconds and the average write rate lands at about 2,300 per second. Rounded deliberately: 2,315 is not worth a second of anyone's time.

  5. 5
    Average to peak

    Because the evening block runs well above the average, size the write path for roughly twice the mean: about 5,000 writes per second at peak.

  6. 6
    The read side is heavier

    Reads dwarf writes. Each daily user views 20 posts, so 100 M users generate 2 billion reads a day — about 23,000 per second on average, ten times the write rate.

  7. 7
    Peak reads close the funnel

    Apply a three-fold peak factor for the burstier read traffic: the read path is sized for about 70,000 views per second. Every downstream decision — caches, replicas, CDNs — chases this number.

Part 5

From posts to petabytes

The second worked number: how much the users' output weighs, per day and across the whole retention window.

  1. 1
    Weigh one post

    Anatomy of one post: a 64-byte identifier, roughly 200 bytes of text, and — for posts that have one — a single 1 MB photo. The text is rounding error; the photo is the story.

  2. 2
    Scale it to a day

    One post in five carries that photo: 40 million photos a day, 40 million megabytes — a flat 40 TB of new media daily, against about 53 GB of text.

  3. 3
    One year fills a shelf

    Keep everything that arrives and one year of media weighs about 15 PB: 40 TB every single day, 365 days in a row. The archive accrues one shelf per year.

  4. 4
    Five years, one archive

    Multiply out the five-year retention window: about 73 petabytes in total, which honest rounding turns into 75. That single number decides object storage, tiers and the bill.

  5. 5
    Estimate what dominates

    The classic envelope move: compare the candidates. Text costs about 53 GB a day, media 40 TB — media outweighs text roughly 750 to 1, so the storage design is a media design.

Part 6

Interview habits

The arithmetic is easy; the discipline around it is what earns the credit. Three habits cover most of it.

  1. 1
    Round on purpose

    Exact division is a trap: 200 M over 86,400 seconds is 2,315 point something. Say ~2,300 and move on — the 0.6% error will never change a design decision.

  2. 2
    Label every unit

    A bare number is ambiguous and will confuse its own author within minutes. Attach the unit to everything: 5 MB, 5 ms and 5 Gbps are three unrelated facts.

  3. 3
    Write the assumptions down

    Whatever you assume, put it on the board and leave it visible. Every later number derives from these four inputs, and follow-up questions get answered by pointing, not re-deriving.

★ Finale

The whole envelope

All three ladders and both worked numbers in one pass: assumptions in, traffic out, storage out, and a verdict a design can be built on.

  1. 1
    Pin the inputs first

    The envelope starts before any arithmetic: four written assumptions. Population 200 million, half active daily, two posts per user per day, one photo in five at 1 MB. Everything after this is derived.

  2. 2
    Run the write path

    Half of 200 M is 100 M daily users; two posts each makes 200 M posts; divided across 86,400 seconds that is ~2,300 writes/s, sized to ~5,000 at peak. The funnel is four hops of grade-school arithmetic.

  3. 3
    Run the read path

    Same users, twenty views each: 2 billion reads a day, ~23,000 per second on average and ~70,000 at peak with the burstier factor. Reads run ten times the writes — that ratio shapes the whole architecture.

  4. 4
    Weigh the storage

    Media math from the unit ladder: 40 M photos a day is 40 TB; five years of retention stacks about 15 PB per year into roughly 75 PB of archive. Text never even shows up on this scale.

  5. 5
    Turn numbers into parts

    Now the envelope pays rent. At a round 1,000 requests per second per frontend, peak writes need about five boxes; a cache that answers nine reads in ten cuts 70,000 peak views down to ~7,000, or about seven more; 75 PB says object storage with a tier per year.

  6. 6
    The envelope closes

    One page, three ladders, four assumptions, and the shape of the system is already visible: a thin write path, a cache-dominated read path, and an archive that grows one petabyte-class shelf per year. Now the real design conversation can start.

🌐 In the wild

In the wild

Envelope math is not a private interview trick — it is written into cloud contracts and open-source playbooks. Here is who publishes the numbers you just used.

  1. 1
    The habit has a home

    Jeff Dean of Google has spent years evangelizing exactly this move: keep a personal table of operation costs, fuse it with quick mental experiments, and let it tell you which designs can even work. The essay that spread the habit is a classic of the field.

  2. 2
    The latency ladder, kept current

    Our latency ladder has a living descendant: an interactive page from Colin Scott that redraws those operation costs with each year's hardware, so the ratios stay honest as machines change.

  3. 3
    The nines, signed in contracts

    Availability nines are not just a table — the big clouds put them in writing. Amazon, Google and Microsoft all publish service-level agreements that commit to 99.9%-class uptime for their compute platforms, with credits when they miss.

  4. 4
    A public drill book

    The unit ladder and the worked-funnel habit live on in an open-source form too: the System Design Primer on GitHub keeps a whole section of these calculations as practice material for exactly the exercise this chapter walked.

  5. 5
    Same envelope, bigger board

    One engineer's napkin arithmetic scales all the way up to contractual uptime and open-source curricula. Learn the three ladders once and every sizing question — in an interview or in production — becomes the same comfortable walk.