1.5. Back-of-the-Envelope Calculations in System Design
Back-of-the-envelope calculations are quick, rough calculations that provide approximate answers. In system design, these calculations help estimate system capacity, performance, and resource requirements.
Why are these calculations important?
They help you quickly validate the feasibility of a design.
They guide architectural decisions by providing order-of-magnitude estimates.
They're often expected in system design interviews to demonstrate your analytical skills.
Key Areas for Calculations
1. Estimating System Capacity
To estimate system capacity, you need to consider:
Storage requirements: How much data will your system store?
Bandwidth requirements: How much data will be transferred?
Computation requirements: How much processing power is needed?
2. Traffic Estimates
For traffic estimates, consider:
Daily Active Users (DAU): How many users interact with the system daily?
Requests per second: How many operations does the system handle per second?
Read vs. Write ratio: What's the proportion of read operations to write operations?
3. Storage Estimates
For storage estimates, think about:
Data size per entity: How much storage does each user, post, or item require?
Total entities: How many users, posts, or items will the system have?
Data growth rate: How quickly will the data volume increase over time?
Useful Numbers to Remember
When doing these calculations, it's helpful to remember some key numbers:
Powers of 2:
2^10 ≈ 1 thousand
2^20 ≈ 1 million
2^30 ≈ 1 billion
Latency numbers:
L1 cache reference: 0.5 ns
Main memory reference: 100 ns
SSD random read: 16,000 ns
HDD seek: 10,000,000 ns
Bandwidth numbers:
1 Gbps network: 125 MB/s
SSD sequential read: 1 GB/s
HDD sequential read: 150 MB/s
Example Calculation: Estimating Storage for a Social Media Platform
Let's estimate the storage needed for user profiles on a social media platform:
Assume 1 million users
Each user profile contains:
User ID (8 bytes)
Name (32 bytes)
Email (32 bytes)
Profile picture URL (200 bytes)
Other metadata (100 bytes)
Total per user: 8 + 32 + 32 + 200 + 100 = 372 bytes
For 1 million users: 372 bytes * 1,000,000 = 372 MB
Adding 20% for indexing and future growth: 372 MB * 1.2 ≈ 446 MB
So, we'd need about 450 MB of storage for user profiles.
Tips for Back-of-the-Envelope Calculations
Round numbers: Use round numbers to simplify calculations.
Use appropriate units: Convert between KB, MB, GB, and TB as needed.
State your assumptions: Always clarify the assumptions you're making.
Sanity check: Does your final answer make sense given the problem?
Practice: The more you practice, the better you'll become at these estimations.
Remember, the goal is to get a reasonable estimate quickly, not to calculate an exact figure. These calculations provide a starting point for more detailed analysis and design decisions.
Last updated