Skip to main content

QPS and Read-vs-Write Modeling

Level 0: Level 0: Interview & Communication Methodmedium30 minestimationread-write-ratio

Derive read and write QPS separately, use the ratio to pick which path to optimize, and model where fan-out multiplies the real load.

The most decision-shaping number: the read:write ratio

The single most decision-shaping number in an estimate is the read:write ratio. It tells you which path to optimize, and optimizing the wrong path is one of the most common ways to lose a design round. A 100:1 read-heavy system (a social feed, a product catalog) wants caches, read replicas, and denormalized read models. A write-heavy or balanced system (an analytics ingest pipeline, a metrics store) wants write batching, append-only logs, and horizontally sharded write paths.

Start by converting DAU to QPS with explicit arithmetic, exactly as in Fermi estimation. Then compute reads and writes separately and take the ratio.

Fan-out: where one write becomes many

The subtlety in feed-like systems is fan-out: one write can generate many logical reads, or one read can require merging many sources. This is the fan-out-on-write versus fan-out-on-read decision.

Check yourself

Before reading the comparison, commit: which delivery strategy does each property belong to?

Reading a feed is one cheap cache lookup
One post triggers an insert into every follower's feed
Posting is a single cheap append
Opening the feed means fetching from every followee and merging
The better fit for a celebrity with 10 million followers
Table
The two failure modes are mirror images, which is why production feeds do both: push for ordinary accounts, pull for the handful of celebrities, and merge the two at read time.
DimensionFan-out on write (precompute)Fan-out on read (merge at query time)
What happensuser posts → push into every follower's feed cacheuser opens feed → pull recent posts from each followee → merge and sort
Read costcheap: one cache GETexpensive: N fetches plus a merge
Write costexpensive: N insertscheap: one append
Good whenreads far outnumber writesa few accounts have enormous fan-out
Breaks ona celebrity with 10M followers: one post becomes 10M insertsa user following thousands of accounts: one read becomes thousands of fetches
The two failure modes are mirror images, which is why production feeds do both: push for ordinary accounts, pull for the handful of celebrities, and merge the two at read time.

Worked example: a feed with 50M DAU, each user reads their feed 20 times/day and posts 0.5 times/day, average 200 followers.

reads/day  = 50M x 20  = 10^9       -> avg  ~10k QPS,  peak ~30k QPS
writes/day = 50M x 0.5 = 2.5 x 10^7 -> avg ~250 QPS,  peak ~750 QPS
read:write ratio ~= 40:1  (read-heavy)

But if you fan out on write, each post writes into ~200 follower feeds. Effective feed-insert QPS = 250 x 200 = 50k QPS of cache writes. So the naive write QPS (250) understates the real write cost by the fan-out factor. This is why the ratio alone is not enough; you must model where the fan-out happens.

Interview nuance: the strong answer usually picks a hybrid. Fan out on write for normal users (cheap reads), but for celebrities with millions of followers, fan out on read (pull their posts at query time) so a single tweet does not trigger tens of millions of feed inserts. Naming this hybrid is a senior signal.

Averages lie: design for the hot key

Access is Zipfian: a small number of hot keys (viral posts, celebrity accounts, trending products) take a hugely disproportionate share of traffic. Your design must survive the hot key, not just the average. A hot key can saturate a single cache node or shard even when the fleet-wide average looks fine, so you plan for replication of hot keys or request coalescing.

Check yourself
Your cache fleet averages 15% utilization with plenty of headroom. A post goes viral. Is the fleet safe?

Finally, translate QPS into a first-order server count. If a tuned application server handles ~10k QPS, then 30k peak read QPS needs at least 3 to 4 app servers behind the load balancer plus headroom, and a cache handling 100k+ ops/sec covers the feed reads.

Recap: derive read and write QPS separately, take the ratio to decide read-optimized versus write-optimized, model where fan-out happens (write vs read, and a celebrity hybrid), and design for the hot key rather than the average.

Check yourself
Your estimate says 40:1 read-heavy, and you chose push fan-out with an average of 200 followers per user. Which conclusion is right?

Apply

Your turn

The task this lesson builds to.

Derive read QPS vs write QPS for a social feed from DAU and a fan-out assumption, then state whether you would optimize the read or write path.

Think about

  1. What is the read:write ratio, and does it point you to cache-heavy or write-optimized design?
  2. Is fan-out done on read or on write, and how does that change QPS?
  3. How do hotspots and Zipfian access change the averages?

Practice

Make it stick

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

Estimate send QPS vs delivery QPS for WhatsApp-scale group messaging assuming 2B users, 40 messages sent per user per day, and an average group size of 8. Decide whether the delivery path or the send path is the scaling bottleneck and justify the fan-out strategy.

Think about

  1. How does group size turn one send into many deliveries, and what multiplier does that put on QPS?
  2. Is messaging read-heavy like a feed, or delivery/write-heavy, and what does that flip in your design?
  3. How does the online-vs-offline split of recipients change the delivery mechanism?