SkillSprout
Chapter 34 · Lesson 2
Intermediate
4 min read

Estimating QPS, Storage and Bandwidth

Overview

Three formulas cover most estimates: how many requests per second, how much storage, and how much bandwidth. Combine them with a worked example and a sanity check, and you can size almost any system in a few minutes.

Detailed Notes

What is a capacity estimate

It answers three questions about a system: how many requests per second (QPS, or queries per second), how much storage over time, and how much bandwidth in and out. Useful terms:

  • DAU: daily active users.
  • Peak QPS: the busiest load, commonly 2x to 5x the average.
  • Read-to-write ratio: how many reads for every write, often 10:1 to 100:1 for consumer apps.

The problem it solves

"Is this a one-server problem or a hundred-server problem?" Each of the three numbers points to a different part of the design. Whichever is largest is the dominant resource and the first thing to design around.

How it works

QPS

text
requests per day = DAU x actions per user per day
average QPS      = requests per day / 100,000
peak QPS         = average QPS x 2 to 5

200 million requests a day is about 2,000 QPS on average, and about 6,000-7,000 at peak. If one server handles about 500 QPS, you need roughly 14 servers for peak, plus spare capacity and redundancy, so perhaps 20.

Storage

text
per day   = new items per day x size per item
per year  = per day x 365
with copies = per year x replication factor (often 3)

50 million posts a day at 300 bytes is 15 GB a day, about 5.5 TB a year, about 16 TB with three copies. Retention matters: keeping 5 years multiplies by 5; deleting after 30 days divides it.

Bandwidth

text
incoming = write QPS x request size
outgoing = read QPS x response size   (x 8 to get bits)

5,800 reads a second x 200 KB is about 1.16 GB/s, roughly 9.3 Gbps. Outgoing traffic is usually the costly direction.

Adjustments to remember: cache hit rate (at 95 percent hits, a database sees only 5 percent of reads, a 20x cut), growth (plan 1-3 years ahead) and headroom (run at 50-70 percent of capacity, not 100).

A simple example

A photo-sharing app: 10 million DAU, 20 percent upload one 2 MB photo a day, each user views 50 thumbnails of 200 KB.

  • Uploads: 2 million a day, about 23 per second (about 70 at peak).
  • Views: 500 million a day, about 5,800 per second (about 17,000 at peak).
  • Storage: 2 million x 2 MB = 4 TB a day, about 1.5 PB a year (about 4.5 PB with 3 copies).
  • Outgoing bandwidth: about 9 Gbps average, about 28 Gbps at peak.

System design example

The numbers decide the design. Uploads are few but heavy, so users upload straight to object storage and a queue feeds workers that resize images. Views are the dominant resource, so a CDN serves them. Photo details (owner, caption) live in a database, not the photos themselves.

Sanity check before trusting the result: do the units cancel to what you want? Divide by users: 4 TB a day over 2 million uploads is 2 MB each, as assumed. Does one machine's network card (10-100 Gbps) cope? If the answer feels absurd, recheck.

Summary

  • Three formulas: QPS = per day / 100,000, storage = items x size x copies, bandwidth = QPS x size.
  • Always estimate peak, not just average.
  • Find the dominant resource and design around it.
  • Sanity-check units and per-user numbers.

Architecture Diagram

Where each estimate leads
Architecture
UsersDAU x actions
QPSservers, cache
Storagesharding, tiers
BandwidthCDN

Each number points to a part of the design.

  1. 1Users and actions give requests per second.
  2. 2Item sizes give storage per day.
  3. 3Response sizes give bandwidth.
  4. 4The largest of the three drives the design.

Common Interview Questions

Chapter quiz

Back-of-the-Envelope Estimation · 5 questions

  1. 1.Roughly how many requests per second is 1 billion requests per day?

  2. 2.A link is 100 Mbps. About how many megabytes per second can it carry?

  3. 3.Why estimate peak load rather than only the average?

  4. 4.Which is roughly true of memory versus SSD access?

  5. 5.50 million posts a day at 300 bytes each, kept with 3 copies, is about how much per year?

0 of 5 answered

Finished this lesson?

0 of 91 lessons done · 0% of the course