Skip to content
prdlk
Esc
↑↓navigate↵open⌘Jpreview
On this page

Back-of-the-Envelope Estimation

Powers of two, latency numbers and availability figures, and how to estimate QPS and storage quickly in an interview.

Introduction

Back-of-the-envelope estimation is a crucial skill in system design interviews. It involves making quick, rough calculations to assess system capacity or performance. According to Jeff Dean, Google Senior Fellow, these estimates help evaluate whether designs meet requirements through thought experiments and common performance benchmarks.

This chapter covers key concepts, methodologies, and examples to build proficiency in scalability and estimation.


Key Concepts

Power of Two

Understanding data volume in terms of powers of two is fundamental:

Powers of two

Powers of two

This knowledge helps in performing accurate storage and bandwidth calculations.


Latency Numbers Every Programmer Should Know

Latency numbers represent the time taken for various operations in computing systems. These provide insights into relative performance:

Operation Latency (2020)
L1 Cache Access 0.5 ns
L2 Cache Access 7 ns
Main Memory Access 100 ns
SSD Random Read 150 µs
HDD Random Seek 10 ms
Round-Trip in Data Center 500 µs
Inter-Region Data Center 150 ms

Availability Numbers

High availability (HA) ensures minimal downtime. Availability is expressed in nines:

Availability Downtime per year
99% (two nines) ~3.65 days
99.9% (three nines) ~8.8 hours
99.99% (four nines) ~52 minutes
99.999% (five nines) ~5.3 minutes
99.9999% (six nines) ~31.56 seconds

Cloud providers like Amazon, Google, and Microsoft aim for SLAs (Service Level Agreements) of 99.9% or higher.


Example Estimation - Twitter QPS and Storage Requirements

Assumptions

  • 300 million monthly active users (MAU).
  • 50% daily active users (DAU).
  • Average tweets/user/day: 2.
  • 10% of tweets contain media.
  • Data retention: 5 years.

Estimations

  1. Query Per Second (QPS):

    • DAU: 300M×50%=150M300\text{M} \times 50\% = 150\text{M}
    • Tweets QPS: 150M×2 tweets/24 h/3600 s≈3500150\text{M} \times 2 \text{ tweets} / 24 \text{ h} / 3600 \text{ s} \approx 3500
    • Peak QPS: 2×3500≈70002 \times 3500 \approx 7000
  2. Media Storage:

    • Tweet Size Components:
      • tweet_id: 64 bytes
      • text: 140 bytes
      • media: 1 MB
    • Daily Media Storage: 150M×2×10%×1 MB=30 TB/day150\text{M} \times 2 \times 10\% \times 1\text{ MB} = 30\text{ TB/day}
    • 5-Year Storage: 30 TB×365×5≈55 PB30\text{ TB} \times 365 \times 5 \approx 55\text{ PB}

Tips for Effective Estimation

1. Rounding and Approximation

Precision is not critical; focus on the process. Simplify complex calculations using round numbers. For example:

  • 99987/9.199987 / 9.1 can be approximated as 100,000/10=10,000100{,}000 / 10 = 10{,}000.

2. Write Down Assumptions

Document assumptions clearly for future reference.

3. Label Units

Avoid ambiguity by labeling units (e.g., 5 MB instead of 5).

4. Common Estimation Scenarios

  • QPS (Queries Per Second): Measure traffic intensity.
  • Peak QPS: Account for traffic spikes.
  • Storage Requirements: Estimate total data needs.
  • Cache Requirements: Evaluate memory requirements for caching.
  • Number of Servers: Calculate hardware needs based on workload.

Last updated on

Was this page helpful?