Course outline
- 01How a computer works
- 02How the Internet works
- 03Introducing the GPU
- 04Tensors and models
- 4.1What is a tensor?soon
- 4.2What is an AI model?soon
- 4.3Training vs inferencesoon
- 05Splitting work across GPUs
- 5.1Why split work across GPUs?soon
- 5.2Data parallelismsoon
- 5.3Tensor parallelismsoon
- 5.4Pipeline parallelismsoon
- 5.5Expert parallelismsoon
- 5.6Which to use whensoon
- 06Serving LLMs with vLLM
- 6.1What is LLM serving?soon
- 6.2Meet vLLMsoon
- 6.3Serving a model with vLLMsoon
Lesson 2.5
Inside a busy server
What a server's CPU and memory do when many requests arrive at once, and what happens when it gets too busy.
In one line
A busy server shares its CPU cores between many requests, gives each one a little RAM, makes the rest wait in a queue, and turns some away when it is full.
Real-life analogy
It is Friday night and our restaurant is packed.
- The restaurant has 4 chefs (CPU cores). Each chef can only cook one dish at any instant, but they switch between dishes quickly.
- Every order needs space on the counter (RAM) for its ingredients.
- New orders that cannot be started yet go on the order rail to wait (the queue).
- When the counter is full and the rail is overflowing, the host at the door says: “Sorry, we are full, please come back later” (a 503).
Where the comparison stops working: a chef needs minutes per dish. A CPU core can handle the steps of a simple web request in a tiny fraction of a second, so a single server can often handle a very large number of requests per second. Also, a server rarely spends all its time “cooking”: much of a request is waiting, for example for a database or for packets to arrive, and the core works on other requests meanwhile.
Diagram
Step by step
In the last lesson, one browser sent one request to one server. But a popular website gets requests from many people at the same time. What happens inside the server’s CPU and memory?
Remember: a server is a computer
A server has the same parts you met in Module 1: a CPU with several cores, RAM, and storage. It runs an operating system and a web server program that listens for requests.
Step 1: requests arrive
Requests arrive as packets from all over the world. The operating system collects them and hands them to the web server program.
Step 2: the work is shared across cores
The web server program usually runs as several workers. For example, the popular web server nginx runs one main process plus several worker processes, and it can be set to start one worker per CPU core.
Each core can only run one thing at a given instant. But the operating system switches between tasks very quickly, so many requests make progress at what feels like the same time.
Step 3: each request uses some RAM
While a request is being handled, the server needs working space for it: who asked, what they asked for, and the answer being built. That space lives in RAM.
More requests at once means more RAM in use. When a request is finished, its space is freed for the next one.
Step 4: the waiting line (queue)
What if requests arrive faster than the cores can handle them? They wait in a queue, a line of requests that have arrived but not started yet.
A short queue is fine: people just wait a tiny bit longer. A long queue means pages feel slow.
Step 5: when it gets too busy
A server cannot grow its queue and RAM use for ever. When it hits its limits, it has a few choices:
- slow down: every request waits longer,
- turn some requests away with a 503 Service Unavailable response (“too busy, try again later”),
- or, in the worst case, run out of memory and crash, which is why turning requests away early is often the safer option.
Some services also limit how many requests one person may send in a short time. They answer 429 Too Many Requests to anyone who goes over.
How big websites cope
Big websites run many servers side by side and spread the requests between them. That way no single server gets overwhelmed. We will meet this idea again when we spread AI work across many GPUs.
Key takeaways
- A server is a computer with cores, RAM and storage, running a web server program.
- The cores share the work, switching quickly between requests.
- Each request needs a little RAM while it is being handled.
- Extra requests wait in a queue. When the server is full, requests are slowed down or turned away with 503.
Recap: a packed restaurant on a Friday night: chefs juggle dishes, every order needs counter space, new orders wait on the rail, and when it is truly full, the host asks people to come back later.
Now you understand what happens inside a server when lots of people arrive at once. Next, the big link to AI: what happens when your request needs a GPU.
Quick check
Pick an answer, then press Check answer. Nothing is recorded.
Sources
This lesson was checked against these pages.
- Beginner's Guide (master and worker processes) · nginx
- About Processes and Threads · Microsoft Learn
- 503 Service Unavailable · MDN Web Docs
- 429 Too Many Requests · MDN Web Docs