How to Do Back of Envelope Calculation in System Design
A
back of envelope calculation is a quick, rough estimate done using simple math to check if a system design idea is feasible. It involves identifying key numbers, making assumptions, and multiplying or dividing them to get an approximate result fast.Syntax
A back of envelope calculation follows a simple pattern:
- Identify key parameters: numbers that matter (e.g., users, requests per second).
- Make assumptions: simplify unknowns with reasonable guesses.
- Apply basic math: multiply, divide, or add to estimate totals.
- Check scale: compare result to known limits or capacities.
This is not formal code but a mental or written formula like:
Estimate = (Number of users) ร (Requests per user per second) ร (Data per request)
plaintext
Estimate = Number_of_users * Requests_per_user_per_second * Data_per_request
Example
This example estimates the bandwidth needed for a video streaming service with 1 million users, each watching 2 videos per day, each video averaging 500MB.
python
users = 1_000_000 videos_per_user_per_day = 2 video_size_MB = 500 days_per_month = 30 # Calculate total data per month in TB total_data_MB = users * videos_per_user_per_day * video_size_MB * days_per_month total_data_TB = total_data_MB / 1_000_000 print(f"Estimated monthly bandwidth: {total_data_TB:.2f} TB")
Output
Estimated monthly bandwidth: 30000.00 TB
Common Pitfalls
Common mistakes include:
- Using overly precise numbers instead of rough estimates.
- Ignoring units or mixing them up (e.g., MB vs GB).
- Forgetting to consider peak vs average usage.
- Not validating assumptions with real data or sanity checks.
Always keep calculations simple and double-check units.
python
wrong_estimate = 1_000_000 * 2 * 500 # Missing days factor correct_estimate = 1_000_000 * 2 * 500 * 30 # Includes days print(f"Wrong estimate (MB): {wrong_estimate}") print(f"Correct estimate (MB): {correct_estimate}")
Output
Wrong estimate (MB): 1000000000
Correct estimate (MB): 30000000000
Quick Reference
| Step | Description |
|---|---|
| Identify key numbers | Pick the main metrics affecting your system. |
| Make assumptions | Simplify unknowns with reasonable guesses. |
| Calculate | Use basic math to estimate totals. |
| Validate | Check if results make sense compared to known limits. |
Key Takeaways
Start with simple, rough numbers to get a quick estimate.
Always clarify and keep track of units to avoid errors.
Use back of envelope calculations to validate feasibility early.
Keep assumptions clear and revisit them as you get more data.
Focus on key parameters that impact your system most.