Skip to main content

Storage, Bandwidth & Cache Sizing

Level 0: Level 0: Interview & Communication Methodmedium30 minestimationstoragecache

Size storage with replication and overhead multipliers, compute ingress and egress separately, and size the cache from the hot working set.

Three capacity numbers, three formulas, three classic mistakes

Storage, bandwidth, and cache are the three capacity numbers that decide your datastore, your CDN strategy, and your cache tier. Each has a formula and a classic mistake.

Storage: metadata and blobs are different systems

The base formula is:

storage = objects/day  x  object size  x  retention (days)

The critical discipline is to separate metadata from blobs. A photo is 2 MB of blob but only ~1 KB of metadata (id, owner, timestamps, storage key, caption). These belong in different systems: blobs in an object store (S3), metadata in a sharded database. Estimating them together hides the fact that your database only needs to hold gigabytes while your object store holds petabytes.

Check yourself
Your raw math says 12 TB of photos over the retention window, stored in a durable RF=3 object store. What number do you quote as provisioned storage?

Two multipliers people forget, both of which change the answer materially:

  • Replication factor. Durable stores keep 3 copies (RF=3), so multiply raw storage by 3. Erasure coding can bring this down to ~1.3x to 1.5x for cold blobs, a real cost lever worth naming.
  • Index and overhead. Secondary indexes, B-tree overhead, and free space commonly add 20 to 50% on top of raw row size for databases.

Bandwidth: ingress and egress separately

bandwidth = QPS  x  payload size
ingress = write QPS x write payload      (upload path)
egress  = read QPS  x read payload       (download/serve path)

Egress is usually the larger and more expensive number, and in cloud pricing egress leaves your provider's network at real dollar cost. A read-heavy media service serving 2 MB objects at 250k QPS is pushing 500 GB/s of egress, which is a "you must use a CDN" signal, not a "size your app servers" signal, because the CDN serves it from the edge and shields the origin.

Cache sizing with the 80/20 rule

You do not cache the whole corpus; you cache the hot working set. The Pareto assumption is that ~20% of data serves ~80% of requests, and often it is far more skewed (the recent and the viral). Size the cache from that hot fraction:

cache size ~= hot fraction (~20%) of the actively-read dataset

For a service with a 4.5 TB actively-read dataset, an 80/20 cut suggests roughly 900 GB of hot data, but in practice the truly hot set is the last few days plus trending items, often a much smaller absolute number like tens to low hundreds of GB. Verify the hit rate assumption: if 100 GB of cache yields a 90%+ hit rate, you have removed 90% of read load from the datastore, which is what justifies the cache economically.

Interview nuance: interviewers probe "how big is your cache and why that size." The winning answer ties cache size to a target hit rate and to the read load removed from the origin, not to a fraction of total storage pulled from thin air.

raw payload -> x replication -> + index/overhead = provisioned storage
hot 20% of reads -> cache size -> target hit rate -> read load removed

Recap: size storage as objects x size x retention with metadata and blobs kept separate, multiply by replication factor and add index overhead, compute ingress and egress bandwidth separately (egress drives CDN), and size the cache from the hot ~20% against a target hit rate.

Check yourself

Sort each piece of a media service's data into the tier where it belongs.

The 2 MB photo blobs themselves
The 1 KB per-photo metadata rows
The hot 20 percent of actively read data
Secondary indexes and B-tree overhead
Five-year-old blobs almost nobody opens

Apply

Your turn

The task this lesson builds to.

Size 5-year storage and the hot-cache tier for a media service, applying the 80/20 rule to decide what lives in cache vs cold storage.

Think about

  1. How do you separate metadata size from blob size in the storage estimate?
  2. What working-set fraction belongs in the hot cache tier?
  3. How does replication factor multiply your storage number?

Practice

Make it stick

A second problem on the same idea, so it survives past today.

Size storage, egress bandwidth, and the cache/CDN tier for Netflix-scale video streaming: assume 250M subscribers, each streaming 2 hours/day at an average 5 Mbps bitrate, and a catalog of 100k titles at an average 15 GB per title (summed across encodings). Decide where the real capacity problem is.

Think about

  1. Is the catalog's total storage actually large by modern standards, or is it a fixed and modest number?
  2. Why is bandwidth about peak concurrency rather than daily totals, and what does the peak egress number force?
  3. How skewed is title popularity, and what does that mean an edge cache needs to hold?