Sub topic 1
Why Estimate Before You Design
Prerequisites
This chapter assumes basic arithmetic, client-server architecture, and familiarity with databases, caches, and load balancers. You may also find simple Python code useful.
Why Estimate Before You Design
Back-of-the-envelope estimation turns a vague requirement into numbers that guide design. Before choosing a database or server type, estimate traffic, storage, bandwidth, memory, and capacity.
These estimates are approximate. Their purpose is to identify the order of magnitude and expose impossible assumptions. An estimate can show that a system needs thousands of requests per second rather than dozens, or terabytes of storage rather than gigabytes.
Stating Assumptions and Rounding to Keep Math Simple
Write down assumptions before calculating. Include user count, activity rate, record size, retention period, and peak behavior. Round values to numbers that are easy to multiply.
For example, use 10 million daily active users instead of 9.7 million, and 10 requests per user per day instead of 9.4. Keep the units visible:
- Users: 10 million
- Requests per user per day: 10
- Record size: 500 bytes
- Retention: 5 years
The result is useful only when someone can inspect and change the assumptions.
dau = 10_000_000
requests_per_user_per_day = 10
seconds_per_day = 86_400
average_qps = dau * requests_per_user_per_day / seconds_per_day
print(round(average_qps)) # 1157Powers of Two and Data Size Units
Computer systems often use powers of two for memory and storage:
| Unit | Approximate size |
|---|---|
| 1 KiB | 1,024 bytes |
| 1 MiB | 1,048,576 bytes |
| 1 GiB | 1,073,741,824 bytes |
For rough system design, decimal units are also common: 1 KB is 1,000 bytes, 1 MB is 1,000,000 bytes, and 1 GB is 1,000,000,000 bytes. State which convention you use. Mixing them can create errors, especially at large scale.
Time Conversions: Seconds per Day and per Year
Memorize these reference values:
- 1 day = 24 × 60 × 60 = 86,400 seconds
- 1 year ≈ 365 days
- 1 year ≈ 31.5 million seconds
To convert daily activity into average requests per second, divide by 86,400. To estimate yearly storage, multiply daily growth by 365. Use 365 unless leap-year precision matters.
Exercise
Why should you state both assumptions and data-size units in an estimate?
Show answer
Assumptions make the calculation reviewable, and explicit units prevent scale errors such as confusing megabytes with mebibytes.