# Scale to Millions of Users

> How an AI app grows from thousands of users to millions: web servers, data, model limits and cost, explained simply for your AI interview.

**In short:** Scaling to millions of users means adding capacity in layers: many stateless app servers behind a load balancer, caches and queues for the data, and a model layer that can be the first bottleneck. Watch rate limits, cache repeated work and keep a fallback ready.

AI and LLM interview question Q357, LLM system design. Advanced, common (our estimate). From Venkat R. Murty's free Interview Kit: https://designervenkat.online/interview/ai/scale-to-millions-of-users

## Say it in 30 seconds

Scaling to millions of users means adding capacity in layers. Many identical web servers sit behind a load balancer, so no single one gets overloaded. Caches and read copies take repeat reads off the database. The model can be the first bottleneck, because each answer costs compute and providers limit how fast you can call them. So I watch the limits, queue the work that can wait, retry after a random short pause, cache repeated prompts, and keep a second provider ready.

## Say it in 2 minutes

I start with the traffic path, because that is where growth breaks first. The web servers should hold no user state of their own, so any server can take any request. A load balancer spreads traffic across them and stops sending work to servers that fail health checks. Auto scaling adds servers when load rises and removes them when it falls. That covers the web tier, and it is the easy part.

The data layer is next. A cache keeps answers to common questions close at hand, so the same question does not hit the database or the model again. Read copies of the database let reads spread out, but a copy can trail the main database for a moment, so I decide which reads can accept slightly old data. Work that does not need an answer now, like overnight summaries, goes into a queue.

The model is the hard part. Providers limit how many tokens you can send per minute, and a sharp spike returns 429 errors. So I cap each team and user in my own code, queue the non-urgent work, retry, waiting a little longer each time and adding a random pause, so clients do not all retry together, and keep a second provider as a fallback. Prompt caching cuts cost and latency for long prompts that repeat, and I track cost per answer from day one.

For a bank's support assistant with two million customers, I would plan for about 1,200 requests a second at peak, using a made-up figure of 80 requests a second per server, and add 30 percent headroom. Then I load test before launch, because the numbers that matter are the ones I measure.

## What does scaling to millions of users mean, in plain words?

Scaling means your app keeps working as more people use it, without getting slow or breaking. Going from a few thousand users to millions takes many small changes, each one placed where the load lands next.

Picture a busy bank branch on the first Monday of the month. One teller can serve only so many people an hour. So the branch opens more counters, puts a person at the door to send each customer to a free counter, and sets up a separate queue for forms that need no teller at all. The building stays the same size, but it gains more ways to take the load.

For an AI app, the teller that runs out first can be the model, the AI that writes each answer. Its limits count tokens, the small pieces of text it reads and writes, roughly a word or part of one. So the plan has to cover three layers: the web servers, the data, and the model.

- **Stateless server:** A server that keeps no user session in its own memory, so any copy can answer any request.
- **Load balancer:** The front door that spreads incoming requests across many servers. It pings each one regularly (a health check) and skips any that stop answering.
- **Cache:** A fast store of answers you already worked out, so you don't do the same work twice.
- **Rate limit:** A cap on how many requests a user or team can send in a set time window.
- **Queue:** A line where jobs wait to be picked up, so a spike makes the line longer instead of crashing the app.

## How do you spread web traffic across many servers?

Start with the web tier. Keep the servers stateless, so the chat history and the login live in a shared store, not in one server's memory. Then any copy can take the next message, and you add copies as the load grows.

A load balancer does the spreading. It sends each request to a healthy server, and auto scaling (adding and removing servers to match the load) makes sure the number of servers follows the day's load, up in the morning and down at night.

*Diagram, How a chat request reaches the model: One chat request, from the customer to the reply. Arrows 3 and 4 show the cheap path: a saved answer goes straight back. Only a miss, arrow 5, pays for the model, so repeat questions never reach it.*
1. The customer's message reaches the front door.
2. The load balancer hands it to a healthy server.
3. The app checks for a saved answer first.
4. A saved answer goes straight back to the customer.
5. A miss sends the question on to the model.
6. The model's answer goes back to the customer.

Worked example. A bank's support assistant serves 2 million customers. Made-up planning figures put the peak at 1,200 requests a second, and one server handles 80 of them. That needs 15 servers. Add 30 percent headroom and you run 20. The load balancer stops sending work to any server that fails its health check, so one dead machine costs a little capacity, and the service keeps running.

> **Tip:** Don't plan around one very big server. Growing one machine upward has a ceiling, and when it fails, every customer fails with it.

## What do you do about the database and repeat work?

Most support traffic repeats. Many customers ask the same handful of questions about fees, card limits and opening hours. A cache keeps those answers, so the reply comes from memory and the model is not called. A cache must never hand one customer's private data to another, so each saved answer is labelled with the customer it belongs to, and only public answers are shared.

- **Cache: Saved answers, very fast.** Keeps the result of work already done. A miss means doing the work again.
- **Read copy: Copies of the database.** Spreads reads over copies of the main database. A copy can trail the main one for a moment, so reads may be a little old.

Use a cache when the same question keeps coming back. Use read copies when reads can accept a little delay and the main database is busy with reads. Both take load off the main database, but neither removes the need to size it.

Work that doesn't need an answer now goes into a queue. A queue holds the jobs and lets workers take them at a pace the system can handle. A spike makes the line longer rather than crashing the app, and the jobs still finish.

Worked example. A call centre with 40,000 calls a day wants a summary for each call. The summaries run from the queue overnight, when load is low, and the morning dashboard reads from a read copy. The live chat database keeps its headroom for customers.

## Why is the model the hardest part to scale?

A model call is slow, and it is metered. Anthropic describes its limits as requests per minute, input tokens per minute and output tokens per minute for each model class. The limit works like a bucket that refills steadily, and going over it returns an HTTP 429 error, which means too many requests.

A sharp rise in traffic can cause 429 errors even when your average use is well under the limit. That is the launch-day problem: the average looks safe, and the peak does not.

So the model layer needs four guards. Put a per-user and per-team cap in your own code. Queue the work that can wait. Retry failed calls with exponential backoff and jitter, which means waiting longer each time and adding a random delay. Keep a second provider for when the first one throttles or fails.

*Diagram, Guarding the model layer: A launch-day spike meets your own caps first, then a queue, so the provider gets calls at a pace it allows. Work that can wait waits, and work that can't moves to a second provider. The user gets an answer or a clear delay, rather than a bare error.*
1. The spike hits your own caps first.
2. Requests inside the caps join the queue.
3. Workers send jobs at the pace the provider allows.
4. Overflow, or jobs the queue sends away from a throttled provider, go to the second.
5. The main provider's answer reaches the user.
6. The backup's answer reaches the user, or a clear delay message does.

> "At Amazon we avoid overload by designing our systems to scale proactively, before they encounter overload situations." (Amazon, on load shedding)
>
> "A retry can increase the load on the system being called, if the system is already failing because it's approaching an overload." (Amazon, on timeouts and retries)
>
> "A sharp increase in usage can also cause 429 errors." (Anthropic, on rate limits)

Retries need the most care. A retry adds load to a system that is already struggling, and if every client retries at the same moment, the retries can be ineffective. Random jitter spreads them out, so the system gets room to recover.

Worked example. A claims assistant at a mid-size insurer hits its per-minute input limit at 9 a.m., when 3,000 claims arrive together. The fix is in code: claims wait in a queue, workers send them at the pace the provider allows, and each adjuster sees a waiting status instead of an error. Overnight summaries move to batch processing, which sends many requests together and lets the provider finish them later.

> **Tip:** Don't promise the model answers every time. Say what happens at the limit: the job waits, moves to the backup, or the customer hears about the delay.

### How would you handle a tenfold spike on launch day?

Plan before the day, not during it. Load test to find the real ceiling. Ask the provider for more capacity early, because a ramp limit caps how fast your organisation's token use on a model can grow. Check how often the cache answers without calling the model (the hit rate) in a test copy of the app.

1. **Test before launch:** Load test the full path, from the load balancer to the model, and find the first layer that fills up.
2. **Raise the limits early:** Ask the provider for more capacity before launch day, since a ramp limit caps how fast your token use can grow.
3. **Shed what you can't serve:** Turn away low-value work with a clear message, rather than let every request slow down together.
4. **Watch four numbers:** Requests a second, queue length, the 429 rate and cost per answer, with a rollback ready.

Shedding is the sharpest tool here. Amazon's engineers found that an overloaded computer keeps taking work, spends more of its time switching between tasks, and becomes too slow to be useful to anyone. That is why shedding, which means refusing some work early with a clear message, is worth planning for.

## What does the interviewer want to hear?

**A strong answer covers**

- [ ] Layers: web, data and model, each with its own limit.
- [ ] Stateless servers behind a load balancer, with auto scaling.
- [ ] Caches and queues take repeat and background work off the hot path.
- [ ] The model is often the bottleneck: rate limits, 429s, retries with jitter.
- [ ] A fallback provider, a cost per answer and load tests before launch.
- [ ] Honest trade-offs: slightly old reads, shed requests, extra cost.

**Common traps**

- Trap: "Just add more servers." Better: Servers don't fix a shared database or a model's rate limit. Find which layer is full first.
- Trap: "We will use the biggest model." Better: Pick the smallest model that passes your tests for each task, and measure its quality and cost on your own data before you choose a bigger one.
- Trap: "The cloud scales for us automatically." Better: Auto scaling adds web servers, not provider quota. The model limits are yours to plan for.

## Can you spot the problem?

**Spot the problem:** A bank's chat assistant keeps each customer's conversation in the memory of the server that answers them. Which problem appears as traffic grows?

A. The server becomes faster, so the cache is no longer needed.
B. A restart, or a different server taking the next message, loses the conversation.
C. The chat history must always be sent to the model in full.
D. The load balancer can no longer send traffic to these servers.

**Answer:** B. Once a server holds user state, a request can't go to just any copy, and a restart or scale-in loses the chat. Keep the conversation in a shared store, so each server stays stateless.

**Quick check:** Your AI app gets ten times normal traffic and starts returning 429 errors. What do you check first?

A. How many web servers the load balancer has
B. Your provider's rate limit, and how much traffic goes straight to the model
C. The size of the database disk
D. The length of the greeting in the chat window

**Answer:** B. A 429 from the model provider means you went over its rate limit. Adding web servers doesn't raise that limit, so check it first, then put a queue, a cache or a fallback in front of the model.

## Can you answer these from memory?

**Flash cards**

- **What does scaling to millions mean?** Adding capacity in layers: web, data and model, each with its own limit.
- **Why keep web servers stateless?** Any copy can take any request, so you can add or remove copies freely.
- **What does a load balancer do?** Spreads requests across healthy servers and skips the broken ones.
- **What is the catch with a read copy?** Updates reach the copy a moment later, so reads can be slightly old.
- **Why add jitter to retries?** So many clients don't retry at the same moment and pile load back on.
- **What can break first in an AI app?** The model's rate limit. Watch the 429 rate and the queue length.

## Likely follow-up questions

- Q356 Design rate limiting. https://designervenkat.online/interview/ai/design-rate-limiting
- Q343 Multi-provider fallback? https://designervenkat.online/interview/ai/multi-provider-fallback
- Q326 Prompt cache vs semantic cache vs KV cache? https://designervenkat.online/interview/ai/prompt-cache-vs-semantic-cache-vs-kv-cache
- Q332 Cold starts and autoscaling? https://designervenkat.online/interview/ai/cold-starts-and-autoscaling
- Q365 Idempotency, queues and retries? https://designervenkat.online/interview/ai/idempotency-queues-and-retries
- Q354 What are the multi-tenant concerns? https://designervenkat.online/interview/ai/what-are-the-multi-tenant-concerns
