← All parts

Capacity Planning

Design Post Search (Full-Text Search) · Part 5
Problem context

Design search over a social product's posts: a user types a multi-word query and gets back the most relevant posts, ranked, out of a corpus of billions that grows every second.

In scope: indexing new posts so they become searchable, answering a full-text keyword query with ranked results, and keeping the index current as posts keep arriving. Out of scope: deep personalization, image or video search, spell-correction and query understanding, and the internals of the learned ranking model.

Scale and usage:

Assume roughly 500 million new posts a day, each with around 300 bytes of text — an illustrative anchor, not a measured fact. New post text alone is 0.5B × 300 bytes ≈ 150 GB/day, or about 55 TB a year; the inverted index built from it runs a similar order of magnitude, so tens of terabytes of new index data every year. That is already past what any single machine can hold. On the read side, assume roughly 500 million searches a day. That's an average of about 500M / 86400 ≈ 5,800 queries per second, and at several times that for peak load, call it on the order of 30,000 queries per second (QPS). The number that actually shapes the design is the fan-out. If the whole inverted index totals roughly 50 TB and each shard holds about 50 GB, that's 50TB / 50GB = 1,000 shards. Because the index is document-partitioned, every query must scatter to all of them — shard pruning by recency or term metadata can trim this in practice, but the baseline design pays the full fan-out. At 30K peak QPS that's on the order of 30,000 × 1,000 = 30 million shard sub-queries per second. A single user query touches roughly a thousand machines. That's the number the rest of the design answers to: it's why each shard ranks and cuts to top-K before returning anything, and why one slow shard threatens every query in flight.

What a strong answer sounds like

State the decision, connect it to a requirement, and name the tradeoff. Ask the interviewer for any product facts you need (users, usage, scale, targets) — they will answer. Keep the design focused on the workload.

Ready for the capacity planning interview?

The AI interviewer asks about this part of Design Post Search (Full-Text Search). The interviewer guides you through topics one by one.