Back-of-the-envelope estimation
A rounded calculation of traffic, storage or latency from a few stated assumptions, made to choose between designs before anything is built. Its value in a round is a number that visibly drives a choice.
What it is
Back-of-the-envelope estimation is a rounded calculation, built from a handful of assumptions you say out loud, that tells you roughly how big a system is: how many requests per second, how many bytes, how many milliseconds. A High Scalability write-up of a talk by Jeff Dean describes the method as thought experiments combined with a few common performance numbers, and reports his view that estimating how alternative designs will perform, without building any of them, is a skill each software engineer should have. Physics teaches the same habit as the Fermi problem: an order-of-magnitude answer assembled from pieces you can guess, which tends to land close because, absent a consistent bias, the guesses that run high and the guesses that run low partly cancel.
| Quantity | How to get it | Where the inputs come from |
|---|---|---|
Requests per second | Actions per day divided by seconds in a day (8.64 × 10^4, call it 10^5) | Daily active users, times actions per user per day |
Peak rate | A multiple of the average that you state and can defend; twice is a simple starting point | Ask whether traffic is bursty; events and time zones push it higher |
Storage per day | Records per day, times bytes per record | Field sizes added up, then rounded up to cover indexes and metadata |
Storage over time | Storage per day, times days of retention | The retention requirement you agreed on earlier |
Bandwidth | Requests per second, times bytes per request | The same record size, applied to the rate |
Google's SRE workbook chapter on non-abstract large system design works an example this way: 5 × 10^5 queries per second, times 8.64 × 10^4 seconds, times 2 KB per log entry comes to 86.4 TB a day, which the authors round up to 100 TB to leave room for indexes. Scientific notation keeps the units straight, and the fields of each log entry are listed and sized before the total is rounded up to 2 KB. Bandwidth follows the same multiplication: a rate of about 10^6 entries a second at 2 KB each is about 2 GB a second, or 16 Gbps.
| Anchor | Value | Use |
|---|---|---|
Seconds in a day | 86,400, close to 10^5 | Turn daily counts into per-second rates |
2^10, 2^20, 2^30, 2^40 | About a thousand, a million, a billion, a trillion: KB, MB, GB, TB | Move between record sizes and totals |
Main memory reference | 100 ns | Cache hits are effectively free next to disk |
Round trip inside a datacenter | 500 µs | A reference point for a hop between services in the same datacenter |
Disk seek | 10 ms | Random disk reads are the thing to avoid |
Read 1 MB sequentially from disk | 30 ms | Sequential disk is far cheaper than random |
Packet California to Netherlands and back | 150 ms | The costliest hop on this list; a reason to keep a request inside one region |
The latency figures date from talks given around 2010. Hardware has moved since; the ByteByteGo chapter notes that some of them are out of date, while the ordering still holds: memory is fast, disk seeks are slow, and a trip across an ocean is slower than any other item on the list. Quote them as orders of magnitude, not as measurements.
The estimate exists to pick a design. Dean's talk shows the move with a page of 30 image thumbnails. Reading the 256 KB images one after another costs 30 seeks at 10 ms each plus the transfer time, about 560 ms. Issuing the reads in parallel costs one seek plus one transfer, about 18 ms, with a note that variance makes 30 to 60 ms more realistic. The numbers let you weigh the two designs against your requirements without building either, and they point at the next variations to consider, caching and precomputed thumbnails. The SRE workbook's example makes the same kind of turn: 5 × 10^5 writes a second against about 200 IOPS per spinning disk would need 2,500 disks, so a single machine on hard disks is ruled out and the design moves on.
The reasoning matters more than the final figure. The SRE workbook says so directly: early assumptions dominate the result, so sound assumptions and visible reasoning are worth more than any particular total. The ByteByteGo chapter gives the interview version of the same advice: round aggressively (treat 99,987 divided by 9.1 as 100,000 divided by 10), write the assumptions down so you can refer back to them, and label units so that a 5 is a 5 MB and not a 5 KB.
When to use it
Use it right after you've agreed on requirements, and again at any point where a component choice depends on size. The ByteByteGo chapter lists the quantities interviewers commonly ask for: queries per second, peak queries per second, storage, cache size and number of servers. Our advice: pick the two or three that bear on your design, keep them brief, and name what each one decides: whether one database handles the write rate, whether the working set fits in a cache, whether media belongs in object storage, whether a table will need to be split.
An example; the inputs are assumptions, not targets.
Assume: 300M monthly users, half active daily, 2 posts/day,
10% of posts carry a 1 MB image, keep 5 years
DAU = 300M x 50% = 150M
Posts/day = 150M x 2 = 300M
Posts/sec = 300M / 86,400 = ~3,500 -> start with one primary; verify when sizing writes
Peak = 2 x 3,500 = ~7,000 -> size the write path for this
Media/day = 300M x 10% x 1 MB = 30 TB/day -> object storage, not the database
Media/5yr = 30 TB x 365 x 5 = ~55 PB -> tiered or cold storage for old mediaThese inputs are invented for the exercise. The arrows on the right are the part we'd insist on: each line ends in the component it points to, phrased as a choice you'll verify rather than a settled fact.
Ask before you assume. If the interviewer has numbers in mind (some problems come with a scale attached), use theirs and skip the guessing. If they tell you to pick, state your assumptions as assumptions and keep going; imperfect but reasonable assumptions are what the method runs on, so aim for a figure you can defend rather than a perfect one.
When not to
Skip the arithmetic when the result wouldn't change the design. If an internal tool or a team dashboard has a load that one service and one database clearly cover, say that in a sentence and spend the time on the harder parts; working out a rate of a few requests per second in detail informs no choice.
Don't lean on it for decisions that hinge on a factor of two. Fermi's famous estimate of the Trinity blast, 10 kilotons against an accepted 21, is held up as a success because it landed within an order of magnitude. That is the method's precision. Whether a working set of 60 GB fits in 64 GB of RAM is not a question an estimate settles; for that, prototype that one part and measure it, as the High Scalability write-up suggests for an input you don't know.
Don't redo it when the interviewer corrects an input. If they say daily media is half again what you estimated, check whether the new figure crosses a limit your storage choice relied on; if it doesn't, say so and continue. Reworking the whole chain for a change smaller than a factor of two spends time on arithmetic the design doesn't need, since the method is built for order-of-magnitude answers.
And don't estimate quantities the round isn't about. A per-request latency budget matters for a chat system or a trading feed; for a nightly batch report, the figures that usually decide the design are total bytes and total run time, so start there and bring in per-operation latency if the run time depends on it.
Compared
| Choice | Lighter option | Fuller option | When the lighter option is right |
|---|---|---|---|
How much to compute | One or two numbers, at the moment a choice depends on them | A full pass up front: traffic, peak, storage, bandwidth, servers | When the design is the same across a wide range of scale, or the interviewer has already set the numbers. The full pass fits a problem defined by scale, such as a feed for hundreds of millions of users. |
How precisely | Powers of ten and a day of 10^5 seconds | Exact inputs and careful arithmetic | Most of the time in the room; order of magnitude is what changes a design. Precision is worth it when a result sits near a hard limit, such as RAM on one machine, and even then a benchmark beats arithmetic. |
Average or peak | Average rate | Average plus a stated peak multiple | When you're sizing storage, which grows on the average. Serving capacity, connection counts and rate limits are sized for the peak. |
Whose numbers | Your own stated assumptions | Numbers you draw out of the interviewer | When they tell you to pick, or the figure is a detail that doesn't swing the design. When they have a scale in mind, theirs wins, and asking is quick. |
Where the figure comes from | Remembered anchors (seconds in a day, disk seek time) | Measured figures from a benchmark or production | In an interview, and for early design. For a purchase order or a capacity plan, measure. |
In a picture
Step 1 of 4
State the assumptions
Say the inputs before any arithmetic: users, actions per user, bytes per record, retention. The interviewer can correct an input now, which is cheaper than correcting a conclusion later.
How to say it in an interview
The common mistake
Quiz
Questions that use this
Related
Sources
- Google Pro Tip: Use Back-of-the-envelope-calculations to Choose the Best Design (High Scalability, on Jeff Dean's talk)
- Non-Abstract Large System Design (The Site Reliability Workbook, chapter 12, Google)
- Fermi problem (Wikipedia)
- Back-of-the-envelope Estimation (System Design Interview course, ByteByteGo)