10,000 users at once: what really happens

System Design · Foundations · Basics · 15 min

Follow a crowd of 10,000 users into a website and add, one layer at a time, everything that keeps it standing.

8:00 pm. The ticket sale opens.

Picture the moment an IPL final's tickets go on sale, Tatkal booking opens at 10 am, or exam results are published. In one second, 10,000 people tap the same button.

Each tap is a request: the browser asks a server for something (a page, an image, "book this seat") and waits for an answer. 10,000 people refreshing about once a second means roughly 10,000 requests every second.

In this lesson you'll build a system that survives that, one layer at a time. The picture on the right follows you as you scroll: watch the dots (requests) and the colour of each box (green = fine, amber = busy, red = overloaded).

Step 0: one server, no plan

The simplest website is one server doing everything: sending the page, the images, checking logins and reading the database.

A typical app server can comfortably answer a few hundred requests a second. 10,000 a second is 40 times more than it can handle. So requests wait in a queue inside the server, the wait grows every second, and soon they time out (the red dots). Users see a spinner, tap refresh, and make it worse.

This is how most college fest and small-shop websites go down on their big day.

Step 1: DNS and a CDN take most of the crowd

Most requests aren't for anything clever. They're for files that are the same for everyone: the page's HTML, JavaScript, CSS, images, fonts. In a typical site that's 70 to 80% of all requests.

A CDN (content delivery network) keeps copies of those files on servers in many cities. DNS, the internet's phone book, sends each user to the nearest copy: Mumbai users to Mumbai, Chennai users to Chennai.

In the picture, the cyan dots never reach your server at all: they bounce back from the edge. Your origin now sees about 2,500 requests a second instead of 10,000, and users get files faster because they come from nearby.

Step 2: a load balancer and many servers

2,500 requests a second is still ten times what one server handles. The fix is horizontal scaling: run many copies of the same app server and put a load balancer in front to share the work.

The load balancer sends each request to a healthy server (round robin, or "least busy"), and stops sending to any server that fails its health check.

For this to work, servers must be stateless: nothing about a user is kept in one server's memory. Sessions live in a shared store (or a signed token), so any server can answer any user. With 10 servers, each now gets about 250 requests a second: busy, but alive.

Step 3: autoscaling for the spike

Ten servers is fine for 10,000 users, but the crowd isn't constant. At 7:59 pm there are 500 users, at 8:00 pm there are 10,000, and at 8:30 pm the tickets are gone.

Autoscaling watches a signal (usually CPU or requests per server) and adds servers when it's high, removes them when it's low. In the simulator the server count follows the crowd, keeping each one under about 70% busy.

One catch: new servers take time to start (tens of seconds to minutes). For a sale at a known time, scale up before it starts (scheduled scaling) instead of waiting for the spike to hit.

Step 4: a cache in front of the database

Now the servers are fine, but they all talk to one database, and databases are much harder to scale than app servers. Look at the database box in the picture: it's the new bottleneck.

Most reads are repeats: the match details, the seat map, the price list. A cache like Redis keeps recent answers in memory. The server asks the cache first; only on a miss does it go to the database, then saves the answer in the cache for next time.

With a 90% hit rate (the yellow dots), the database sees a tenth of the reads. The hard part is invalidation: when a seat is booked, the cached seat map must be updated or expire quickly, or people try to buy seats that are gone.

Step 5: read replicas and a connection pool

Reads that miss the cache still hit the database, and writes (bookings, payments) always do.

Read replicas are copies of the database that stay in sync with the main one (the primary). Reads can go to any replica; writes go only to the primary. Four copies means roughly four times the read capacity. Replicas can be a moment behind the primary, so read your own just-written data from the primary.

A connection pool matters just as much. Every database connection costs memory; 10,000 requests each opening their own would knock the database over by themselves. A pool keeps a fixed number of connections open and shares them.

Step 6: a queue for slow work

Booking a ticket triggers slow jobs: sending the confirmation email and SMS, generating a PDF ticket, updating analytics. If the request waits for all of them, every booking takes seconds and holds a server busy.

Instead, the server puts a small message on a queue ("send ticket to booking 4821") and answers the user straight away. Workers take jobs off the queue at a steady pace. In the picture, orange dots flow to the queue and workers drain it.

During a spike the queue simply gets longer for a while; nothing falls over. Jobs must be idempotent (safe to run twice), because a worker can crash halfway and the job will be retried.

Step 7: rate limits and a waiting room

Not every request is a real fan. Bots scrape prices and try to grab tickets thousands of times a second. A rate limiter caps how many requests one user, IP or API key can make (say, 10 a second) and answers the rest with 429 Too Many Requests: the purple dots that stop early.

For the biggest moments (a ticket drop with 2 lakh fans for 30,000 seats), sites add a virtual waiting room: users get a place in line and are let in at a pace the system can handle. It feels slower, but it's fair and nobody gets an error page.

Step 8: degrade gracefully, and watch it all

Even with everything above, something will struggle: the recommendations service, the review stars, the "people also bought" box. Graceful degradation means the core journey (see seats, pay, get the ticket) keeps working while extras are switched off. A circuit breaker stops calling a failing service for a while instead of waiting on it every time.

And you can't fix what you can't see: dashboards for requests, errors and latency per layer, and alerts that wake someone up before users notice.

Press around in the full simulator: switch off one defence at a time and watch which box turns red.

The whole journey, in one breath

Of 10,000 requests a second: about 7,500 never leave the CDN. Of the rest, bots are turned away at the rate limiter. A load balancer spreads about 2,250 across autoscaled servers. The cache answers most reads, replicas share the rest, the primary takes the writes, and slow jobs wait calmly in a queue.

In an interview, this is the story to tell for any "design X for millions of users" question: start simple, find the bottleneck, add the layer that removes it, repeat. The System Design track goes deep on every layer you met here.

More in Foundations

Previous: What Is System Design? · Next: How to Approach a System Design Interview