I have been designing systems for fifteen years, and whenever I talk about the consumer app I have been building, one question always comes up: “How did you scale it?”
I will keep the product specifics out of this piece, so the numbers are rounded and the details generalised. What matters more is the sequence of decisions, the pain behind each one, and what I would do differently.
The honest answer is less glamorous than people expect. I did not draw a perfect architecture on day one. I started with one server, waited for something to hurt, fixed that, and repeated. Eight times.
This is that story, in the order it happened, including the mistakes. If you are building something right now, I hope it saves you a few 2 a.m. wake-up calls.
Day One: One Server, Ten Users
When the app launched, the application and the database lived on the same machine. Ten users, CPU around 10%.
People ask if that felt irresponsible. It did not, and it still doesn’t. A single server is cheap, easy to debug and easy to reason about. The most expensive mistake I see experienced engineers make is building for ten million users when they have ten.
So I built nothing extra. I just watched the graphs.
Layer 1: I Gave the Database Its Own Server
What hurt: Somewhere around a thousand users, the app got slow. CPU was pinned near 96%. My application and my database were fighting over the same CPU, memory and disk.
What I did: I moved the database onto its own machine. That was it. No clever technology, just separation.
What I learned: The first scaling win is almost always the cheapest one. Before you reach for something new, ask whether two things are simply sharing a box they should not be.
Layer 2: I Put a Load Balancer in Front
What hurt: At roughly ten thousand users, a burst of attention from social media sent a wave of new traffic, and my single app server maxed out at 100% CPU.
What I did: I ran several identical app servers behind a load balancer. If one fails, traffic simply flows to the others.
What I learned: I could do this only because my app servers were stateless. I had to move sessions and uploads out of local memory and disk first. If you plan to scale horizontally, make statelessness a rule early, because it is painful to retrofit.
Layer 3: I Added a Cache
What hurt: The app tier was fine now, but the database was sitting at about 92% CPU. Looking at the queries, I found something almost embarrassing: the same catalogue data was being fetched from the database on every single request, though it changed only a few times a day.
What I did: I put Redis in front of the database. Database CPU dropped to roughly 30%.
What I learned: Cache what is read often and changes rarely. But decide how you will invalidate it before you add it. A cache is a promise to serve data that may be slightly stale.
Layer 4: I Brought Content Closer with a CDN
What hurt: Users far from my servers started reporting that images were slow or not loading. My servers sat in one region, and every image traveled the whole way on every request.
What I did: I put a CDN in front of static assets, so images and files are served from a location near the user.
What I learned: Some latency is physics. You cannot tune your way out of distance. You can only move the content closer.
Layer 5: I Added Read Replicas
What hurt: Even with the cache, reads were overwhelming my primary database, which was back at about 94% CPU. Like most apps, mine reads far more than it writes.
What I did: I added read replicas. Writes go to the primary, and reads spread across the replicas.
What I learned: Replicas lag. For anything that must reflect a user’s own action immediately, like a transaction they just completed, I read from the primary. Everything else can live with a few hundred milliseconds of delay.
Layer 6: I Moved Slow Work into a Queue
What hurt: During a seasonal sale, every order synchronously sent an SMS, sent an email and generated an invoice before the user saw a confirmation. Checkout jammed and CPU hit 97%.
What I did: I confirmed the order immediately, then published events to a queue. Background workers now handle notifications and invoices at their own pace.
What I learned: If the user does not need the result right now, do not make them wait for it. A queue also stops one flaky dependency, like an email provider, from breaking checkout. The price is that I now own retries, idempotency and dead-letter handling.
Layer 7: I Sharded the Data
What hurt: As the user base approached the millions, the data no longer fit comfortably on one database, and writes had hit the ceiling of the biggest machine I could reasonably run.
What I did: I partitioned the data across multiple databases using the user ID as the shard key.
What I learned: Sharding is the most expensive decision on this list. Cross-shard queries, transactions and resharding are all harder, and a bad shard key creates hot spots you will live with for years. I did it only after I had exhausted indexing, query tuning, caching, replicas and archiving old data. If you can avoid sharding, avoid it.
Layer 8: I Finally Took Monitoring Seriously
What hurt: One night around 2 a.m., the app went down and nobody on my team knew. We found out from users.
What I did: I added real monitoring: latency percentiles, error rates, saturation, queue depth, replication lag, with alerts that fire before customers notice.
What I learned: I put this layer last in the story, and that is the mistake. If I could redo one thing, I would add monitoring on day one, right alongside Layer 1. You cannot scale a system you cannot see.
The Night the Cache Almost Killed Me
By this point, everything looked healthy: about 35% CPU at peak. Then one night the cache cluster restarted.
The cache came back empty. Every request missed and went straight to the database, which was sized to handle only what the cache doesn’t absorb. The database buckled, and the whole application went down with it.
This is called a cache stampede. The very layer I added to protect my database had quietly become something the system could not survive without.
Here is what I changed afterwards, and what I would build in from the start now:
Request coalescing: only one request rebuilds a missing key; the others wait for it.
TTL jitter: random expiry times so keys do not all expire together.
Cache warming: pre-load hot keys before a restarted node takes traffic.
A replicated cache: no single node as a hard dependency.
Load shedding: rate limits and circuit breakers in front of the database, so it degrades instead of collapsing.
The Whole Journey on One Page
Layer 1, Separate database: Pain: App and DB fighting for CPU. Cost: Network hop, more servers.
Layer 2, Load balancer: Pain: One app server saturated. Cost: Had to make servers stateless.
Layer 3, Cache: Pain: DB hammered by repeat reads. Cost: Invalidation, stampede risk.
Layer 4, CDN: Pain: Slow assets for distant users. Cost: Cache control, extra cost.
Layer 5, Read replicas: Pain: Reads exceeded one DB. Cost: Replication lag.
Layer 6, Message queue: Pain: Slow work blocking checkout. Cost: Retries, idempotency.
Layer 7, Sharding: Pain: Data and writes outgrew one DB. Cost: Complexity, painful resharding.
Layer 8, Monitoring: Pain: Outage nobody noticed. Cost: Alert discipline.
What I Would Tell My Younger Self
Measure before you add. Every layer above started with a graph, never a hunch.
Every new component is a new way to fail. Ask what happens when it goes down before you ship it.
Try the boring fix first. An index or a query rewrite will often delay sharding by years.
Monitor from day one, not after the first outage.
Scale the team with the system. Runbooks, on-call and clear ownership matter as much as the boxes on a diagram.
If you take one thing from this: scale step by step, add each component only when a bottleneck appears, and design for its failure too.
I would love to hear which layer hurt you most in production. Just reply to this email. I read every response.











