0% completed
Back-of-the-Envelope, Revisited
On This Page
- The Estimate You Do Not Need
- Round Hard, Because Your Inputs Are Soft
- Estimate in Ranges, Not Points
- The Three Estimates That Decide Architecture
- Sanity Checks That Catch Real Errors
- The Senior Decision: Stop When the Answer Is Decided
1. The Estimate You Do Not Need
Most estimation in system design discussions gets done and then ignored. Somebody computes the daily request volume, writes it on the board, and designs exactly what they would have designed without it. The arithmetic was correct and the exercise was decoration.
The question that separates a useful estimate from a decorative one is short.
Would a very different answer have led to a different design?
If a number could come back ten times larger and the design would not move, that number is not worth computing. If it could come back twice as large and a component would have to change, compute it carefully and say what the threshold is.
A few estimates almost always pass that test:
- Peak write rate, because it decides whether one machine is enough.
- Working set size against available memory, because it decides whether reads can be served without touching disk.
- Fan-out, because one write that becomes a million writes is a different system from one that becomes three.
And a few almost never do:
- Total storage after five years, because you will have changed the design twice before then.
- Request volume to three significant figures, because every input it came from is uncertain by more than that.
- Anything you would scale by adding a machine, because the answer does not change the architecture, only the invoice.
So before computing anything, say out loud what decision the number is for. That single sentence turns estimation from a ritual into an argument, and it is also what an interviewer is listening for.
2. Round Hard, Because Your Inputs Are Soft
The most common error in estimation is not arithmetic. It is false precision: carrying six digits through a calculation whose first input was a guess.
Treat a day as 100,000 seconds rather than 86,400. That is a 16 percent error, and it is invisible beside a user count you estimated within a factor of three. Rounding to powers of ten is not sloppiness when the inputs are soft; it honestly reflects how much you actually know.
A small set of anchors is worth holding in memory, because you will reach for them constantly:
- A day is about 100,000 seconds. A month is about 2.5 million, and a year about 30 million.
- A million requests per day is about 12 per second. This one converts an impressive-sounding number into an unimpressive one, and it does so instantly.
- One gigabit per second is about 125 megabytes per second.
- Memory is roughly 100 nanoseconds away, a fast local disk roughly 100 microseconds, and a machine in the same data center roughly half a millisecond. Memory to disk is a factor of a thousand, which is the gap worth remembering. The network then adds only a few times more on top of disk, which surprises people who expect it to be the expensive step.
- Crossing a continent costs tens of milliseconds, and crossing an ocean costs around a hundred. These are set by the speed of light in fiber, so no engineering effort will move them.
Notice what that list does not contain: anything that changes quickly. The durable numbers are ratios and physical limits. Prices, instance sizes and device throughput all move, so look those up rather than memorizing them.
3. Estimate in Ranges, Not Points
Every input to an estimate is uncertain, and a single number hides that. Worse, uncertainty compounds in a way most people underestimate.
Suppose three inputs are each uncertain by a factor of two in either direction, which is normal for user counts, request sizes and growth rates. Multiply them and the product spans a factor of eight above and eight below. The single number sitting in the middle of a sixty-four-fold range looks far more certain than it is.
So carry three numbers rather than one: a low case, a likely case, and a high case. Then look at where the range sits relative to the decision you are making.
- If the whole range falls on one side of the threshold, you are finished. The uncertainty does not matter, and saying so out loud is a strong move.
- If the range straddles the threshold, you have found the one input worth measuring rather than guessing. That is the most valuable output an estimate can produce.
That changes what estimation is for. You are not trying to find the right number. You are trying to find out whether you already know enough to decide, and if not, exactly which measurement would settle it.
4. The Three Estimates That Decide Architecture
Most design-relevant estimates fall into three families, and each has a rough threshold where the design changes shape.
Peak write throughput. Compute writes per second at peak, not average. The question it answers is whether a single primary can hold the write path. Low thousands per second is comfortable for a relational database on good hardware. Tens of thousands is possible with care. Beyond that you are choosing between partitioning the writes, batching them, or accepting a different storage engine. Reads do not force this decision, because reads can be spread across copies and writes mostly cannot.
Working set against memory. The working set is the data actually touched in a typical window, which is almost always far smaller than the total. Compare it to the memory you can afford. If the working set fits, reads are a solved problem. If it is ten times larger, you are designing a cache with a hit rate you must now estimate, and the design has a new failure mode. The interesting case is when the working set is two or three times memory, because that is where the answer depends on access skew.
Fan-out. For each write, how many other things must change? One row is a normal system. A hundred is a background job. A million is an architecture, and probably a different one for the worst case than for the common one. Fan-out is the estimate that most often eliminates an otherwise reasonable design, and it is the one candidates compute least often.
5. Sanity Checks That Catch Real Errors
Arithmetic errors in estimation are usually not small. They are factors of a thousand, caused by a unit slip. Four checks catch nearly all of them, and they take seconds.
- Make the units cancel. Write the units beside the numbers and confirm that what remains is what you claimed to compute. Requests per second times bytes per request gives bytes per second, and if your answer is in bytes, something went wrong.
- Ask whether the answer is a lot. Convert the result into something with a familiar size. Is that one laptop or a thousand racks? Is it one percent of a disk or a hundred of them? A number you cannot picture cannot be checked.
- Compare against a system you know. If your estimate says this product needs more storage than a well-known service with a hundred times the users, the estimate is wrong, not the product.
- Check both ends. Compute the result from the inputs, then take the result and work backwards to one input. A silent factor of a thousand rarely survives being derived twice.
The habit worth building is doing these out loud. An interviewer cannot see you check your work silently, and a colleague cannot either.
6. The Senior Decision: Stop When the Answer Is Decided
Estimation has a natural stopping point, and it is earlier than most people think. You stop when one more digit of precision would not move the decision.
That gives a simple procedure, and it is the whole lesson.
- Name the decision. "I want to know whether writes fit on one primary."
- Name the threshold. "One primary is comfortable to roughly ten thousand writes per second."
- Estimate in a range, rounding hard.
- Compare the range to the threshold. If it is clearly on one side, decide and move on. If it straddles, name the one input you would measure.
That protects you from the most common failure in a design discussion: spending ten minutes on arithmetic that was never going to change anything. The time was not the real cost. The real cost is that the arithmetic looked like rigor, so nobody asked whether the right question was being answered.
What the interviewer is scoring: the signal is not whether your arithmetic is correct. It is whether you said what the number was for before you computed it. A candidate who announces "I want to know if this fits on one database, and the threshold is around ten thousand writes a second" has shown the entire skill in one sentence. The arithmetic that follows is almost a formality. Expect to be pushed on uncertainty: "how confident are you in that user count?" is an invitation to show that you know which input the answer is sensitive to. The strongest candidates also say when they are finished, which sounds like "the low end of my range is already above the threshold, so I do not need a better number."
Flashcards Review
The test for whether an estimate is worth computing
Reading Progress
0%
On This Page
- The Estimate You Do Not Need
- Round Hard, Because Your Inputs Are Soft
- Estimate in Ranges, Not Points
- The Three Estimates That Decide Architecture
- Sanity Checks That Catch Real Errors
- The Senior Decision: Stop When the Answer Is Decided