Skip to content
Dev Dump

Back of the Envelope Calculation

1️⃣ What is Back-of-the-Envelope Calculation?

Section titled “1️⃣ What is Back-of-the-Envelope Calculation?”

Back-of-the-envelope (BOE) calculations are quick, rough estimates used to evaluate the feasibility of a system before designing it in detail. These help in estimating storage, bandwidth, memory, and processing needs efficiently.

2️⃣ Understanding Data Size Conversions

Section titled “2️⃣ Understanding Data Size Conversions”

Before diving into calculations, let’s define unit conversions to avoid confusion:

Unit 📏Equivalent Value
1 KB (Kilobyte)1,000 bytes = 10³ bytes
1 MB (Megabyte)1,000 KB = 10⁶ bytes
1 GB (Gigabyte)1,000 MB = 10⁹ bytes
1 TB (Terabyte)1,000 GB = 10¹² bytes
1 PB (Petabyte)1,000 TB = 10¹⁵ bytes
1 EB (Exabyte)1,000 PB = 10¹⁸ bytes
NameValueScientific NotationZeros
Thousand1,00010³1,000
Million1,000,00010⁶1,000,000
Billion1,000,000,00010⁹1,000,000,000
Trillion1,000,000,000,00010¹²1,000,000,000,000
Quadrillion1,000,000,000,000,00010¹⁵1,000,000,000,000,000
Quintillion1,000,000,000,000,000,00010¹⁸1,000,000,000,000,000,000
  • 1 Million = 1M = 10⁶
  • 1 Billion = 1B = 10⁹
  • 1 Trillion = 1T = 10¹²

Quick Reference for Calculations

📌 Example:
A 5 MB file = 5 × 1,000 × 1,000 bytes = 5,000,000 bytes (5 million bytes).

3️⃣ Traffic Estimation (Requests Per Second - RPS) ⚡

Section titled “3️⃣ Traffic Estimation (Requests Per Second - RPS) ⚡”

Estimating the number of requests a system handles helps in designing load balancers, databases, and caching systems.

Total RPS = Total Users * Active Users Ratio * Requests per Active User per Second

🔹 Given:

  • A system has 100 million registered users.
  • 10% are active daily10 million active users.
  • Each user makes 10 requests per minute.

🔹 Calculation:

  • Requests per second per user = (10/60 = 0.167) requests per second.
  • Total RPS:
    10,000,000 * 0.167 = 1,670,000 { RPS (1.67 million requests/sec)}

Estimating storage helps in planning databases, replication, and backup strategies.

Total Storage per Year = Data per Request * Total Requests per Year

🔹 Given:

  • Each request generates 2 KB of data.
  • System handles 1.67 million RPS.
  • Requests per year:
    1.67 * 10^6 * 60 * 60 * 24 * 365
    = 52.6 * 10^{12} { (52.6 trillion requests per year)}

🔹 Storage Required:

52.6 * 10^{12} * 2 { KB} = 105.2 { PB per year}

🔹 Considering Replication & Backups:

  • If 3x replication, total storage = 315.6 PB per year.
  • If backups are kept for one year, total storage needed = 631.2 PB.

📌 Scale Reference:

  • 1 PB = 1,000 TB
  • 1 PB ≈ Storage of 223 million HD movies (4.5 GB each)

5️⃣ Memory Estimation (Cache & DB Indexing) 🛠️

Section titled “5️⃣ Memory Estimation (Cache & DB Indexing) 🛠️”

Determining cache size ensures efficient system performance.

Cache Size = Data per Object * Objects Stored in Cache

🔹 Given:

  • 20% of requests are cached.
  • Each cached response = 2 KB.
  • System handles 1.67M RPS.

🔹 Calculation:

  • Data in cache per second =
    1.67 * 10^6 * 0.2 * 2 = 670 { MB per second}
  • Data stored in cache for 1 hour:
    670 * 3,600 = 2.41 { TB}
  • Total RAM required ≈ 2.5 TB.

6️⃣ Quick Cheat Sheet for BOE Calculations 📌

Section titled “6️⃣ Quick Cheat Sheet for BOE Calculations 📌”
Metric 🛠️Formula
Requests Per Second (RPS)Users × Active Ratio × Requests per User
Storage Per YearRPS × Data per Request × Seconds in a Year
Cache SizeCache % × RPS × Data per Object × Cache Retention Time
BandwidthRPS × Data per Response
CPU Servers Needed(RPS × CPU Time per Request) / (Cores per Server × Utilization)

Calculating required servers is crucial for capacity planning and cost estimation.

Number of Servers = (RPS × CPU time per request) / (Cores per server × Core utilization × Seconds)

🔹 Given:

  • System handles 1.67M RPS
  • Each request takes 50ms (0.05s) of CPU time
  • Each server has 32 cores
  • Target CPU utilization: 80% (0.8)

🔹 Calculation:

Servers = (1,670,000 × 0.05) / (32 × 0.8 × 1)
= 83,500 / 25.6
≈ 3,262 servers
Request ComplexityCPU TimeMax RPS per Core
Light (cache hit)1ms1,000
Medium (DB read)10ms100
Heavy (DB write/compute)50ms20
Very Heavy (complex computation)100ms10

Example with Buffers:

Base servers needed = 3,262
Peak load buffer (2x) = 6,524
Growth buffer (50%) = 9,786
Redundancy (30%) = 12,722 servers