Back-of-Envelope Estimation
🎒 Explain Like I'm 5: Planning a School Trip
Imagine your class is going on a field trip! Before you go, you need to figure out how many buses, lunch boxes, and water bottles you need!
🚌 The Problem:
- • Your school has 1,000 students
- • Each bus holds 50 students
- • Each student needs 1 lunch box and 2 water bottles
🤔 Let's Calculate!
- • Buses needed: 1,000 students ÷ 50 per bus = 20 buses
- • Lunch boxes: 1,000 students × 1 box = 1,000 lunch boxes
- • Water bottles: 1,000 students × 2 bottles = 2,000 water bottles
📚 The Lesson:
This is what engineers do! They estimate what resources they need BEFORE building a system. Instead of buses and lunch boxes, they calculate servers, storage, and bandwidth!
What is Back-of-Envelope Estimation?
Back-of-envelope estimation is a quick, approximate calculation to understand system requirements. It's done 'on the back of an envelope' - meaning you don't need perfect accuracy, just ballpark numbers to make informed decisions!
Why is it Important?
- ✓ Makes system design interviews easier - shows you can think through problems
- ✓ Helps estimate infrastructure costs before building
- ✓ Identifies potential bottlenecks early
- ✓ Guides technology choices (SQL vs NoSQL, caching needs, etc.)
Power of 2 Table (Memorize This!)
Computer memory and storage use powers of 2. These numbers are essential!
Latency Numbers Every Programmer Should Know
Understand how long different operations take:
Traffic Estimation
Step 1: Calculate Requests Per Second
Example: Twitter-like App
Read Requests:
Write Requests:
Storage Estimation
Step 2: Calculate Storage Needs
Continuing Twitter Example:
Text Storage:
Image Storage:
Total Storage: 219TB + 36.5PB ≈ 37PB for 5 years
Bandwidth Estimation
Step 3: Calculate Network Bandwidth
Read Bandwidth:
Write Bandwidth:
Total Peak Bandwidth: ~36GB/sec incoming + outgoing
Memory/Cache Estimation
Step 4: Estimate Cache Size
80/20 Rule:
80% of traffic goes to 20% of content. Cache the hot 20%!
Cache popular tweets:
Need ~25-30GB of cache memory for optimal performance