In a system design interview, sometimes you are asked to estimate system capacity or performance requirements using a back-of-the-envelope estimation. According to Jeff Dean, Google Senior Fellow, “back-of-the-envelope calculations are estimates you create using a combination of thought experiments and common performance numbers to get a good feel for which designs will meet your requirements” [1].

You need to have a good sense of scalability basics to effectively carry out back-of-the-envelope estimation. The following concepts should be well understood: power of two [2], latency numbers every programmer should know, and availability numbers.

Power of two

Although data volume can become enormous when dealing with distributed systems, calculation all boils down to the basics. To obtain correct calculations, it is critical to know the data volume unit using the power of 2. A byte is a sequence of 8 bits. An ASCII character uses one byte of memory (8 bits). Below is a table explaining the data volume unit (Table 1).

PowerApproximate valueFull nameShort name
101 Thousand1 Kilobyte1 KB
201 Million1 Megabyte1 MB
301 Billion1 Gigabyte1 GB
401 Trillion1 Terabyte1 TB
501 Quadrillion1 Petabyte1 PB

Table 1

Latency numbers every programmer should know

Dr. Dean from Google reveals the length of typical computer operations in 2010 [1]. Some numbers are outdated as computers become faster and more powerful. However, those numbers should still be able to give us an idea of the fastness and slowness of different computer operations.

Operation nameTime
L1 cache reference0.5 ns
Branch mispredict5 ns
L2 cache reference7 ns
Mutex lock/unlock100 ns
Main memory reference100 ns
Compress 1K bytes with Zippy10,000 ns = 10 µs
Send 2K bytes over 1 Gbps network20,000 ns = 20 µs
Read 1 MB sequentially from memory250,000 ns = 250 µs
Round trip within the same datacenter500,000 ns = 500 µs
Disk seek10,000,000 ns = 10 ms
Read 1 MB sequentially from the network10,000,000 ns = 10 ms
Read 1 MB sequentially from disk30,000,000 ns = 30 ms
Send packet CA (California) ->Netherlands->CA150,000,000 ns = 150 ms

Table 2

Notes


ns = nanosecond, µs = microsecond, ms = millisecond

1 ns = 10^-9 seconds

1 µs= 10^-6 seconds = 1,000 ns

1 ms = 10^-3 seconds = 1,000 µs = 1,000,000 ns

A Google software engineer built a tool to visualize Dr. Dean’s numbers. The tool also takes the time factor into consideration. Figures 2-1 shows the visualized latency numbers as of 2020 (source of figures: reference material [3]).

Image represents a comparison of various operation times in a computer system and network, visualized using colored squares whose sizes are proportional to the duration of each operation.  On the left, a vertical column shows different operations with their corresponding times in nanoseconds (ns):  L1 cache reference (1ns), branch mispredict (3ns), L2 cache reference (4ns), mutex lock/unlock (17ns), sending 2000 bytes over a commodity network (44ns), an SSD random read (16,000ns), and reading 1,000,000 bytes sequentially from memory (3,000ns).  These are represented by progressively larger black squares.  Below, green squares represent a round trip within a datacenter (500,000ns) and another operation (1,000,000ns). On the right, blue squares represent main memory reference (100ns),  compressing 1KB with Zippy (2,000ns), and another operation (10,000ns). Red squares represent an SSD sequential read (49,000ns), a disk seek (2,000,000ns), a disk sequential read (825,000ns), and a packet roundtrip between California and the Netherlands (150,000,000ns).  Each square's size visually corresponds to the time taken, with conversions to microseconds (µs) and milliseconds (ms) provided for context.  The image effectively illustrates the relative performance differences between various operations, from very fast cache accesses to significantly slower network and disk operations.
Figure 1

By analyzing the numbers in Figure 1, we get the following conclusions:

Availability numbers

High availability is the ability of a system to be continuously operational for a desirably long period of time. High availability is measured as a percentage, with 100% means a service that has 0 downtime. Most services fall between 99% and 100%.

A service level agreement (SLA) is a commonly used term for service providers. This is an agreement between you (the service provider) and your customer, and this agreement formally defines the level of uptime your service will deliver. Cloud providers Amazon [4], Google [5] and Microsoft [6] set their SLAs at 99.9% or above. Uptime is traditionally measured in nines. The more the nines, the better. As shown in Table 3, the number of nines correlate to the expected system downtime.

Availability %Downtime per dayDowntime per weekDowntime per monthDowntime per year
99%14.40 minutes1.68 hours7.31 hours3.65 days
99.99%8.64 seconds1.01 minutes4.38 minutes52.60 minutes
99.999%864.00 milliseconds6.05 seconds26.30 seconds5.26 minutes
99.9999%86.40 milliseconds604.802.63 seconds31.56 seconds

Table 3

Example: Estimate Twitter QPS and storage requirements

Please note the following numbers are for this exercise only as they are not real numbers from Twitter.

Assumptions:

Estimations:

Query per second (QPS) estimate:

We will only estimate media storage here.

Tips

Back-of-the-envelope estimation is all about the process. Solving the problem is more important than obtaining results. Interviewers may test your problem-solving skills. Here are a few tips to follow:

Congratulations on getting this far! Now give yourself a pat on the back. Good job!

Reference materials

[1] J. Dean.Google Pro Tip: Use Back-Of-The-Envelope-Calculations To Choose The Best Design:
http://highscalability.com/blog/2011/1/26/google-pro-tip-use-back-of-the-envelope-calculations-to-choo.html

[2] System design primer:
https://github.com/donnemartin/system-design-primer

[3] Latency Numbers Every Programmer Should Know:
https://colin-scott.github.io/personal_website/research/interactive_latency.html

[4] Amazon Compute Service Level Agreement:
https://aws.amazon.com/compute/sla/

[5] Compute Engine Service Level Agreement (SLA):
https://cloud.google.com/compute/sla

[6] SLA summary for Azure services:
https://azure.microsoft.com/en-us/support/legal/sla/summary/