Back-of-the-Envelope Estimation

How to turn daily users into requests per second, storage, bandwidth and server counts with a few rounded anchors, and what interviewers expect.

14 minLesson 4 of 6
On this page
  1. Where estimates feed into a design
  2. Requests per second
  3. Storage
  4. Bandwidth
  5. Servers and cache memory
  6. Nuances interviewers probe
  7. In the interview
  8. What to practise next

Back-of-the-envelope estimation is a quick calculation, done with rounded numbers, that turns a product's size ("10 million daily users") into the load the system must handle: requests per second, storage, bandwidth and the number of servers. Interviewers ask for it so that the design is based on the size of the problem. The answer decides whether one database is enough, whether images need a CDN and whether a cache is worth adding.

Without a quick way to estimate, candidates either skip the numbers and design for an unknown load, or spend several minutes on exact long division, such as 100 million divided by 86,400 to get 1,157.4. The estimate only needs the right order of magnitude, so the method on this page is to memorise a few anchors, scale them by factors of 10, and finish each result with the design decision it leads to.

Where estimates feed into a design

Each part of the system gets one estimate: request rate for the servers, writes for the database, hot data for the cache, and photo bytes for storage and bandwidth.Users to API servers (how many) (requests/s, bandwidth); API servers (how many) to Cache (memory) (hot data); API servers (how many) to Database (writes) (writes/s, rows); API servers (how many) to Photo storage (size) (bytes stored).UsersAPI servers (howmany)Cache (memory)Database(writes)Photo storage(size)requests/s, bandwidthhot datawrites/s, rowsbytes stored
Each part of the system gets one estimate: request rate for the servers, writes for the database, hot data for the cache, and photo bytes for storage and bandwidth.

The sections below cover the four calculations in the order an interviewer expects them: requests per second, then storage, then bandwidth, then servers and cache memory. Every number comes from a given or from an assumption you state out loud.

Requests per second

The starting point is converting a daily count into a per-second rate. A day has 86,400 seconds, which you round to 100,000. Dividing by 100,000 is dividing by 10 and then by 10,000, which gives the anchor that the rest of the page uses.

Events a dayAbout, a second
1 million10
10 million100
100 million1,000
1 billion10,000

The exact value is about 15% higher, because 1 million a day is really 11.6 a second. That is well inside the error of the other assumptions, so it is enough to say once that you rounded down. For monthly figures the matching anchor is that 1 billion a month is about 400 per second.

To get the request rate, multiply the per-second rate of the users by the number of requests each user makes in a day. The table shows the average rate for the common combinations.

Daily users1 request each10 each100 each
1 million10/s100/s1,000/s
10 million100/s1,000/s10,000/s
100 million1,000/s10,000/s100,000/s
1 billion10,000/s100,000/s1 million/s

The single value worth remembering is that 10 million daily users making 10 requests each is about 1,000 requests per second. The other cells follow by multiplying by 10. You will also need two assumptions, and you should state both because the interviewer may want different values. The first is that peak traffic is about 3 times the average for a consumer app, which is a rule of thumb and varies by product. The second is that reads outnumber writes by about 10 to 1 unless the problem says otherwise, so the write rate is the request rate divided by 10.

The usual mistake here is to size the system for the average. Servers and databases fail at the peak, so the peak is the number that every later calculation should use.

Storage

Storage is the number of items multiplied by the size of one item. The table gives the three products that cover almost every case, using 1 KB for a row or message and 1 MB for a photo.

Count× 1 KB (a row, a message)× 1 MB (a photo)
1 thousand1 MB1 GB
1 million1 GB1 TB
1 billion1 TB1 PB

To get the storage for a year, multiply the daily amount by about 400. The real factor is 365, and 400 is easier to multiply and errs on the side of having too much disk. Then multiply by 3 for the copies, because durable storage normally keeps three replicas. One million 1 KB rows a day is 1 GB a day and about 400 GB a year, or 1.2 TB with copies. One million 1 MB photos a day is 1 TB a day, about 400 TB a year, and about 1 PB with copies.

The result matters because it decides where the data lives. Hundreds of gigabytes fit on one database server. A petabyte does not belong in a database at all, so the photos go to blob storage and the database keeps a small row with a reference to each photo.

Estimate: Photo storage for one year

How much disk do one year of uploaded photos need, counting all copies?

You know
  • 1 million photos uploaded a day
  • 1 MB per stored photo
  • 3 copies of every photo for durability

Show the working
  1. Anchor: 1 million × 1 MB = 1 TB a day
  2. Per year: 1 TB × 400 ≈ 400 TB
  3. Three copies: 400 TB × 3 = 1,200 TB, about 1 PB

Estimate 1 PB (anything from 300 TB to 3 PB is a good answer)

A petabyte a year rules out keeping photos in a database. They go to blob storage, and the database keeps a small row per photo.

Bandwidth

Bandwidth is the request rate multiplied by the size of each response. 1,000 responses a second at 1 MB each is 1 GB per second. Network links are sold in bits per second, so multiply by 8: 1 GB per second is 8 Gbit/s. Because that is an average, a peak of 3 times the average needs about 24 Gbit/s.

The decision it drives is usually whether to use a CDN. A few Gbit/s is already more than you want your own API servers to send, so large files such as images and video are served from a CDN or from blob storage and not through the application servers. If the figure is a few megabytes per second, there is nothing to decide, and you should say so and move on.

Estimate: Photo bandwidth

How much photo data per second goes out to viewers on average?

You know
  • 10 million daily users
  • Each views 10 photos a day
  • 1 MB per photo

Show the working
  1. Anchor: 10 million users at 10 each is 1,000 views a second
  2. Anchor: 1,000 a second × 1 MB = 1 GB/s

Estimate 1 GB/s (anything from 300 MB/s to 3 GB/s is a good answer)

1 GB/s is 8 Gbit/s on average and about 24 Gbit/s at a 3x peak. That is a job for a CDN, not for your API servers.

Servers and cache memory

The number of servers is the peak request rate divided by what one server can handle. The capacities below depend on hardware and on how heavy each request is, so present them as assumptions and not as facts. Numbers to know has a longer list that includes latencies.

One machineHandles about
Stateless API server1,000 requests a second
Relational database primarya few thousand writes a second
In-memory cache node100,000 simple reads a second

Servers are not run at full capacity, because a server at 100% load has no room for a spike or for the loss of a neighbour, so plan for about 70%. Each 1,000 requests a second on average becomes 3,000 at peak, and 3,000 ÷ 700 is about 4.3, which rounds up to 5. That gives a rule of thumb that every 1,000 average requests a second needs about 4 or 5 API servers, and also means that 10 million daily users at 10 requests each is a fleet of about 5 servers. The table applies the same arithmetic to several sizes, assuming 10 requests per user a day, 1 write for every 10 reads, a peak of 3 times and 70% load.

Daily usersAverage requestsPeak requestsWritesAPI servers
100 thousand10/s30/s1/s1 (run 2)
1 million100/s300/s10/s1 (run 2)
10 million1,000/s3,000/s100/s5
100 million10,000/s30,000/s1,000/s43
1 billion100,000/s300,000/s10,000/s430

Two servers are listed for the small cases even though one would handle the load, because a service with a single server goes down whenever that server does. The write column matters for the database: 10,000 writes a second is beyond one relational primary, which leads to sharding, while 100 writes a second is not worth discussing.

Cache memory is the same count-times-size calculation, applied only to the hot data. If 10 million items are read often and each is 1 KB, they need 10 GB, which fits in memory on one cache node. The question to ask is how much data is read often, because the whole dataset is usually far too large and does not need to be cached. See Caching for how that data is kept.

Nuances interviewers probe

Peak versus average

The average rate is what you compute first, but it sizes nothing, because the system has to survive the busiest period. Apply a peak factor of about 3 and say that it is an assumption. For products with sharp spikes, such as ticket sales, a sale launch or a live event, the peak can be 10 or 100 times the average, and the interviewer may give you that number. If they do, use it and do not substitute your own rule.

Forgetting copies

Storage without replication is about a third of the disk you will buy, so apply the factor of 3 for copies out loud.

How precise to be

Estimates built on guesses about user behaviour are accurate to within a factor of 2 or 3, and that is enough to choose an architecture. Extra precision is wasted unless a result lands close to a real limit, such as 900 requests a second against a server that handles 1,000. In that case, say that the margin is thin and plan for a second server.

In the interview

Estimate after clarifying the requirements and before designing the API, as described in the framework. Compute only the numbers that can change the design, which are usually the peak request rate, storage and bandwidth, and say for each one what it means for the design. A number that does not lead to a decision should be skipped.

Questions to expect:

  • "How many requests per second is that?" Convert the daily count with the anchor that 1 million a day is about 10 a second, multiply by the requests per user, and then give the peak as about 3 times the average. State the assumptions you made along the way, and finish with how many servers that is.
  • "How much storage do you need?" Multiply the items per day by the size of one item, multiply by 400 for a year, and by 3 for copies. Then say where that amount can live, for example that a few terabytes fit on a database cluster but a petabyte needs blob storage.
  • "How many servers do you need?" Divide the peak rate by what one server handles at about 70% load, round up, and add a spare so that one failure does not cause an outage. If the interviewer gives a different capacity per server, use theirs.
  • "Does this need a CDN?" Multiply the peak request rate by the response size to get bandwidth. If the result is several Gbit/s of large files, yes, because the CDN takes that traffic away from the origin. If it is small, a CDN is an optimisation and not a requirement.
  • "How accurate is your estimate?" It is accurate to within a factor of 2 or 3, which is enough to choose the architecture. You only recompute more carefully when a number lands close to a real limit.
Estimating out loudStrong answer
Interviewer

Assume 10 million daily users. How much traffic is that?

You

Can I assume each user makes 10 requests a day? 10 million requests a day is about 100 a second, so 100 million requests a day is about 1,000 a second. I will assume the peak is 3 times that, so 3,000 a second, which needs around 5 API servers at 70% load. That means the API tier is not the hard part of this design.

Interviewer

Then what is?

You

The photos are. If 1 million are uploaded a day at 1 MB each, that is about a petabyte a year with three copies. If users view 1,000 photos a second, that is 1 GB a second going out. So the design is mostly about blob storage and a CDN.

Quick check

A chat app has 10 million daily users, each sending 100 messages a day. About how many messages a second is that on average?

Users upload 10 million photos a day at 1 MB each. About how much is that a year, for one copy?

Images go out at 1 GB/s on average. What network capacity is that in the units links are sold in?

Average load is 1,000 requests a second and one server handles 1,000. Why is one server not enough?

What to practise next

Next, turn the requirements into endpoints in API Design. For estimates inside a full case, see Design Video Streaming, where bandwidth drives most of the design.