One system, five orders of magnitude
Every mechanism in this tier has been introduced on its own, as an answer to a problem stated in the abstract. That is the wrong shape for how any of this actually happens. In a real system the mechanisms arrive in an order, each one forced by a specific thing that broke last week, and the order is the part a course can teach that experience otherwise takes six years to supply.
So here is one system — a social feed, the same one the lab asks you to draw — walked from a thousand users to a hundred million. At each step: what broke, what was added, and what it cost. Nothing is added before something breaks. That constraint is the entire lesson.
1,000 users — one box, and no architecture at all
A single virtual machine runs the application and Postgres side by side. The feed is one query: join the user's follows to posts, order by time, take twenty. It returns in 8 ms because the whole database fits in memory and there are forty thousand rows in it.
What to do here: nothing. This is not a starter design to be embarrassed about, it is the correct design, and the instinct to add a cache "before we need it" is the instinct this course exists to suppress. There is no bottleneck. Adding a component now means adding a failure mode, a monitoring surface and a deployment step in exchange for solving nothing.
10,000 users — the first thing to break is the code
Feed loads creep to 900 ms. The intuitive diagnosis is "we've outgrown the database". The actual cause, almost every time, is the N+1 query: the feed fetches twenty posts, then issues one more query per post to get the author. Twenty-one round trips where two would do.
The fix is a join or a batched load, it takes an afternoon, and it is a 10× improvement. Note what did not happen: no component was added. The first rung of Lesson 0.03's ladder is "make the code faster", and it stays the right first move for a surprisingly long time.
100,000 users — indexes, then a bigger box
Traffic grows and the feed query slows again. This time it is real: the posts table is at ten million rows and the query is scanning. An index on (author_id, created_at) restores it (Lesson 3.02).
Then CPU sits at 70% at peak. The answer is the boring one — move to an instance with four times the cores and memory, in a maintenance window, for a few thousand rupees a month. It buys two years. This step gets skipped constantly because it feels like giving up, and it is almost always the highest-return decision available.
1M users — the first real split
Now one machine genuinely cannot do both jobs. Two changes, in this order:
- Separate the application tier from the database and run several application servers behind a load balancer (4.01). They hold no state, so this is close to free — the one thing it breaks is sessions kept in process memory, which now have to move to a shared store.
- Add read replicas (4.04), because the read:write ratio is 10:1 and reads are the pressure.
And immediately you inherit a bug that did not exist at any previous size. A user posts, is redirected, and their post is not there — the write went to the primary, the read went to a replica that was 200 ms behind. Replication lag became visible to users the moment you added the replica. The fix is to route a user's own reads to the primary for a few seconds after they write. It is a small patch, and it is the first time the system's correctness depends on understanding distributed state.
5M users — the feed query stops being a query
The join across follows and posts is now the top consumer of database time, and no index makes a fan-in over hundreds of followed accounts cheap. Two responses, both from this tier:
- Cache the rendered feed per user (4.02), with a short TTL.
- Denormalise the fields the feed needs — author name and avatar onto the post row (3.05) — so rendering stops joining at all.
The cost lands within a fortnight. A popular key expires, ten thousand concurrent requests miss simultaneously, and all of them hit the database at once: a cache stampede. You add a per-key lock and jittered TTLs. Denormalisation bills you separately — a user changes their display name and it is now wrong on four million posts until a background job catches up.
10M users — the write path, and the queue
Writes now saturate the primary, and read replicas cannot help because every replica applies every write. This is the size at which the feed's central decision can no longer be deferred: fan-out on write or on read.
You choose fan-out on write — when someone posts, push the post id into each follower's precomputed timeline — because it makes the read a single range scan. But two hundred writes cannot happen inside the poster's request, so they move to a queue with workers draining it.
The cost is a change in the product's semantics, not just its architecture: the feed is now eventually consistent, a post takes seconds to appear for followers, and a worker crash means retries, which means the fan-out must be idempotent. You have crossed from Tier 4 into Tier 6, and the crossing was forced by a write rate.
50M users — everything becomes a cluster
The feed cache no longer fits on one machine, so it becomes a cluster with consistent hashing (4.05) — chosen over modulo because adding a node should move 1/N of the keys, not 80% of them. Immediately, hot keys: one viral post makes one shard glow while its siblings idle, and you are splitting keys across sub-keys and monitoring per-shard load.
Media has outgrown the database too, so images move to object storage with a CDN in front (3.08, 4.03) — which turns out to be the largest single latency and cost win of the entire journey, because most bytes stop travelling from your origin at all.
100M users — the two problems with no clean answer
Two things break that no earlier mechanism addresses.
The celebrity. Fan-out on write, correct since 10M, is catastrophic for an account with 80 million followers: one post becomes 80 million writes. The answer is a hybrid — push for ordinary accounts, pull celebrity posts at read time and merge — which means two code paths, a threshold to tune, and a read path that is now a merge and re-sort.
Storage. The write volume exceeds one primary regardless of hardware, so the data is sharded by user id. This is the least reversible decision in the whole story, and it takes back capabilities you have relied on since the first paragraph: cross-shard joins, multi-row transactions, and the ability to answer any question that does not include the shard key without fanning out to every shard.
Then, if users are global, multi-region — and Lesson 14.01 is a tier away for a reason.
| 1K — nothing broke | one box |
| 10K — N+1 query | fix the code |
| 100K — table scan, then CPU | index, then a bigger box |
| 1M — one box can't do both | app tier + replicas → lag is visible |
| 5M — the join is the bottleneck | cache + denormalise → stampede, staleness |
| 10M — writes saturate the primary | fan-out via queue → eventual consistency |
| 50M — cache exceeds one box | hash ring, CDN → hot keys |
| 100M — celebrities, write volume | hybrid fan-out, sharding → no joins |
The two things to take from this
First, every row of that table was a response to evidence. Nobody added a queue because queues are good; they added one because two hundred synchronous writes were sitting in a user's request. That chain — symptom, measurement, mechanism, new cost — is what a design conversation should sound like.
Second, and less comfortable: the overwhelming majority of systems stop at 1M and are right to. Four rows of that table cover almost every product that will ever exist, including profitable ones with real customers. The bottom half is not a more advanced version of the top half — it is a set of expensive concessions extracted by scale nobody has yet reached.
Reading this as a roadmap. It is a post-mortem of a path, not a plan for one, and a team that implements the last row on day one has bought every cost in the right-hand column with none of the pressure that justified them — sharded storage with no joins, an eventually consistent feed, a hash ring to operate, two fan-out paths to keep correct, for ten thousand users a single Postgres would have served in 8 milliseconds. The skill this lesson is trying to build is not knowing the sequence. It is knowing where on it you currently are, which is a question about your metrics rather than your ambitions.