SevyDevy

Module 8 · From One Server to Millions · Lesson 33 of 35

How to scale an app to millions of users, step by step

14 minFree System design course · Beginner to intermediateLesson 8.2By Saket Bhatnagar

Researched and drafted with AI, reviewed and edited by Saket Bhatnagar.

In short

  • How to scale an app to millions of users: add one part at a time, each triggered by a number, starting from one server.
  • The order: one server, a separate database, a bigger box, stateless servers behind a load balancer, cache and CDN, replicas, queues, then shards and zones.
  • Cost grows far slower than users: SeatJaldi’s bill grew 1,500 times while users grew 1 lakh times.
Soon

Video lesson · coming soon

How to scale an app to millions of users, step by step

Lala, your AI mentor, will walk you through this lesson in a short animated video. Until then, everything is here to read and try.

  1. 01 ₹18 lakh, and nobody can explain it
  2. 02 Vaishali’s dosa stall grows
  3. 03 Eight stages, eight red numbers
  4. 04 The final picture, tagged by stage
  5. 05 Match the symptom to the step
  6. 06 Redraw it, then explain it in 45

SeatJaldi’s national final sale runs clean, with no outage. The ₹40 crore Series A is in, yet Meera Kulkarni is more worried than relieved.

Investors asked her: “What did you buy, and when should you have bought it?” The bill is ₹18 lakh a month for 1 crore users. She cannot explain one rupee of it.

Arjun Nair joined at 100 club members. He can name every part, but not the number that made the team buy it. Sandeep Patil shrugs: every graph is green.

Zoya Mirza draws eight boxes on the whiteboard, one per stage. “Every one of these was bought on a day a number went red,” she says. “But one purchase on this journey came before any number asked for it. What?”

How to scale an app to millions of users, and in what order?

You scale in steps, adding one part at a time, and each step is triggered by a number that has gone red. A number goes red when it crosses what the system can take.

  • Find the number that has gone red.
  • Add the smallest part that moves that exact number.
  • Measure again, and wait for the next red number.

Keep one line in your head: add each part only when a number says you need it. Most often, that number is the peak from lesson 7.

SeatJaldi at stage 8, with the stage each part arrived

Files come from the CDN. Requests pass a load balancer pair to stateless servers, which check the cache, then the databases, and queue slow work.

Diagram connections:

  • App and web to CDN (Static files)
  • App and web to Load balancer pair (Requests)
  • Load balancer pair to Stateless app servers (Healthy server)
  • Stateless app servers to Redis cache (Check first)
  • Stateless app servers to Primary, replicas, shards (Read, write)
  • Stateless app servers to Queue and workers (Slow work)
  • App and web: Stage 1: this plus one server.
  • CDN: Stage 5: files near the user.
  • Load balancer pair: Stage 4: picks a healthy server.
  • Stateless app servers: Stage 4: any server serves anyone.
  • Redis cache: Stage 5: seat map and sessions.
  • Primary, replicas, shards: Stages 2, 6 and 8.
  • Queue and workers: Stage 7: PDF, SMS, email later.
  • You have seen this: a ticket site opens fine at 10 am but shows a waiting page at noon on sale day. It was sized for the noon peak, and the waiting page protects the servers.
  • A food app shows menu photos at once, but “Place order” is slower. Photos come from a nearby edge server; the order must reach the database.
  • Asked to scale an app, a student says “Kafka and shards” without asking about today’s users. The interviewer wanted the number behind each step.

How do you scale a web application step by step?

Eight steps, each with its own trigger. This is the order to learn, not the order SeatJaldi bought them. The bigger box came before the separate database, and shards and regions before the queue.

Try it yourselfSeatJaldi’s eight growth stagesAt each stage, read the number that went red, the smallest fix, and what the monthly bill did.

So what came early? Not one of the eight boxes. It hid inside the database: in lesson 15, Arjun added six extra indexes at once, to be safe. Four served no screen and slowed writes at noon, so he dropped those four.

How do you know which step to take next?

Read the symptom, find the number behind it, then pick the smallest part that moves that number. Vaishali knows this: a second counter will not help if the batter shop behind it is slow.

Try it yourselfWhich step fixes this symptom?Seven symptoms from SeatJaldi’s growth. Tap the step that fixes the number behind each one.

What just happened? Each symptom pointed at one number, and only one step moved it. The wrong options were real parts, but each fixes a different number.

What does each step cost, and which can you undo?

Each step has a monthly cost and a cost to undo, so the hard-to-undo steps come last. Vaishali can sell back a bigger tawa, but not ten cities.

  • Cache, lesson 11’s sum: 95% hits, a 0.5 ms hit and a 5 ms database read. A miss checks the cache first: 0.95 × 0.5 + 0.05 × (0.5 + 5) = 0.75 ms, against 5 ms uncached.
  • Users grew 1 lakh times; the bill grew 18,00,000 / 1,200 = 1,500 times.
  • Resharding with hash mod N, four shards to five: a key stays only if key mod 4 equals key mod 5. Of keys 1 to 20, only 1, 2, 3 and 20 do, so 80% move.
Step, monthly cost, how hard to undo
StepMonthly costHow hard to undoMeasure first
Bigger box₹9,000Simple: resize back downServer CPU
Load balancer, stateless servers₹4,800 for four (₹13,800 with the database box)Moderate: needs a shared session storeRequests a second
Redis and CDN₹3,500 and ₹4,000Quick to switch off, if the database copesDatabase CPU and hit rate
ReplicasMore machinesQuick to remove; code must handle lagReads per write, primary CPU
Queue and workersBrokers and workersHard once code relies on later workCheckout time
Shards and regions₹3 lakh in all once two regions ranHardest: resharding moves most dataWrite rate and disk size

At every stage, ask lesson 1’s three questions again. Single point of failure? 10 times the load, 1,67,000 a second? A slow part it needs?

Try it yourself

  1. Redraw from memory

    Draw the seven final boxes without looking.

  2. Tag each box

    Write the stage it arrived in, its trigger number, and any rupee cost you remember.

  3. Pick one to skip

    Circle one box you would not build for 100 users, and write why.

  4. Check your answer

    You are right if every box has a stage and a trigger, the order matches the stepper, and you named one box to skip.

Back at the whiteboard, Zoya taps the database box. “The indexes were the same mistake as buying a stage early, only smaller.” Arjun grins. “Wait, so the order was never fashion. It was eight red numbers.”

Meera reads the growth map, and the bill makes sense: ₹12 a member at the start, 18 paise a user now. Like Vaishali’s ten cities, shards and regions waited until a number demanded them. Her plan for investors: add the next part when the next number goes red.

Arjun will run SeatJaldi’s fresher interviews. Can he explain all this in 45 minutes, and can a fresher?

Check yourself

Check yourself

Meera wants all eight stages built now, so nobody worries again. What does the mental model say?

Pick an answer to see why it is right or wrong.

Check yourself

Which number best justifies stage 4, many stateless servers behind a load balancer?

Pick an answer to see why it is right or wrong.

Remember these three

  1. Add each part only when a number says you need it, then measure again.
  2. Read the symptom, find its number, then pick the smallest part that moves it.
  3. Hard-to-undo steps come last, and shared parts make each user cheaper.

Questions people ask

How to scale an app to millions of users?
Add one part at a time, each when a number says you need it. The usual order is a separate database, a bigger box, stateless servers, cache and CDN, replicas, queues, then shards.
How many users can one server handle?
It depends on what each request does. This course assumes about 200 requests a second for a small server. Measure your own, since a cache hit costs far less than a write.
Do you need microservices to reach millions of users?
No. Many large systems grew as one well-split app first. Splitting is a team and data decision, not a requirement of scale, and these steps work either way.