Why estimate at all
After this: Say what an estimate is for, judge whether one is in the right order of size, and list the assumptions behind it.
On this page · 5 sections · 3 checks
Your team is planning a photo app. Someone says: "Ten million people will use it every day." Then someone else asks: "So do we need one server, or a hundred?" Nobody can measure the answer, because the app does not exist yet. But the answer still matters a lot. One server and a hundred servers are different designs, with different costs.
A rough number, on purpose
You can still answer. Take a few round numbers you believe, multiply and divide them, and look at the size of the result. You are not trying to be exact. You are trying to tell one server from ten, and ten from a hundred.
This kind of quick sum is called a : the sums are short enough to fit on the back of an envelope.
What does "right" mean for a rough answer? It means the is right: the answer has the right number of digits. 5,000 and 5,787 are both thousands, so they agree. 500 and 5,787 do not: one is ten times the other. In interviews you will hear this called the order of magnitude.
The smallest example
A school website. 2,000 students each open it 5 times a day. Does it need more than one server?
- Requests per day: 2,000 × 5 = 10,000.
- A day has 86,400 seconds. Lesson 2 shows where that number comes from.
- 86,400 ÷ 10,000 = 8.64. So the site gets about one request every 9 seconds.
- In the tutorial "What happens when you open a website", one server finished 400 requests per second.
One request every 9 seconds against 400 every second: one server is more than enough. Notice that the exact values did not matter. If every number were twice as big, or half as big, the answer would still be one server. That is the point of an estimate: it is good enough when a better guess would not change the decision.
Write every assumption down
The school sum used three guesses: 2,000 students, 5 visits each, and 400 requests per server. Each is an : a value you choose to believe for now, because you cannot measure it yet.
A good estimate starts with a table of every assumption. Here is the one this tutorial uses from start to finish, for a photo app we will call Snapshot. Its first line counts : the different people who use the app on a given day.
| Assumption | Value |
|---|---|
| Daily active users | 10 million |
| Photos each user views per day | 50 |
| Photos each user uploads per day | 0.1 (one photo every ten days) |
| Size of one photo | 2 MB |
| Size of one photo's record in the database | 1 KB |
| Busiest time of day (the peak) | 2 × the average |
| Requests one server handles per second | 400 |
Two lines need a word now. "Peak = 2 × average" is an assumption we chose, not a fact about photo apps: some services see five times their average or more. Lesson 3 explains what a peak is. And 400 per server comes from tutorial 1, where 8 workers each spent 20 ms on a request; a server with heavier work per request handles fewer.
Why a table? Because each line can be argued with on its own. If someone thinks users will view 100 photos a day, not 50, they change one line, and the sums are done again. Nobody has to argue with the final answer as a whole.
By the end of the tutorial this table becomes three numbers: about 11,600 requests per second at the peak, 730 TB of new photos a year, and 29 servers.
Check yourself
Months later, an exact count says Snapshot gets 5,787 photo views per second. Which estimate, made before the app existed, was in the right order of size?
A school website gets 10,000 requests a day, about one every 9 seconds. One server handles 400 requests per second. How many servers does it need?
Why does the Snapshot estimate start with a table of every assumption?
Interview lens and honesty
- Say what a back-of-the-envelope estimate is for: telling one server from ten, and ten from a hundred, before anything can be measured.
- Judge whether a rough answer is in the right order of size: 5,000 and 5,787 both have four digits, 500 and 50,000 do not.
- Write every assumption in a table first, so that each guess can be checked and changed on its own.
- Say plainly that "peak = 2 × average" is an assumption, and that some services see five times their average or more.