The single-box app

Every website starts as one computer. Learn the four parts inside it, and which one gives up first when a crowd shows up.

20 min read

one box
cpu
mem
disk
net

disk saturates first - the site is "slow" while CPU idles

Every website is a shop

Forget computers for a second. Imagine a small shop with one worker behind the counter. A customer walks in, asks for something, the worker fetches it, hands it over. Next customer. That's it - that is also exactly how a website works.

When you open a website, YOU are the customer. Your click is the request ('one homepage, please'). Somewhere in the world there's a computer - the server - playing the role of that worker. It hears your request, fetches what you asked for, and sends it back. That whole round trip usually takes less than a second.

Every giant website you know - YouTube, Amazon, WhatsApp - started life as one single computer doing this. One shop, one worker. This lesson is about that one computer: what's inside it, and what happens when too many customers show up at once.

Imagine it like this: A website is a shop. You are the customer, your click is the order, and the server is the worker who fetches what you asked for.

Words you just learned
server
- a computer whose job is to answer requests from other computers
request
- one ask, like 'give me the homepage' - every click sends one

The four parts inside the worker

Our shop worker has four things they use to serve customers, and the computer has the exact same four. Once you can name them, you can diagnose almost any slow website.

The brain (CPU). This does the thinking: reading your request, doing the math, preparing the answer. A faster brain thinks faster - but it can only think about a few things at once.

The desk (RAM / memory). This is where the worker keeps things they're using RIGHT NOW - open orders, notes. It's very fast to grab things from the desk, but the desk has limited space. When it's full, things start falling off. On a computer, 'falling off' means programs crash.

The notebook (disk). This is where everything is written down permanently - every customer, every order ever made. It never forgets, but flipping through it is much slower than glancing at the desk. On a computer this is the hard drive, and it's where the database lives.

The door (network). Every customer and every answer passes through the door. A wide door lets lots of people through per second; a narrow one makes them queue outside. On a computer this is the internet connection.

Remember these
  • Brain = CPU: does the thinking
  • Desk = RAM: fast, small, temporary
  • Notebook = disk: slow, huge, permanent
  • Door = network: how requests come in and answers go out
Words you just learned
CPU
- the computer's brain - it does the actual work
RAM
- fast temporary workspace - wiped when the machine restarts
disk
- permanent storage - slow but never forgets
network
- the connection requests and answers travel through

Now send in a crowd

Here's the interesting part. When a crowd shows up, the four parts do NOT get tired at the same speed. One of them always gives up first - and which one it is decides what the failure looks like.

Try it below. Drag the slider and watch: the notebook (disk) fills up long before the door (network) even breaks a sweat. That's very common in real life - the database's disk is the first thing to drown, while everything else looks fine.

Try it yourself: drag the slider to send more people to the shop, and watch which part gets tired first.
100 visitors
brain (CPU)
12%
memory (RAM)
8%
notebook (disk)
17%
door (network)
5%

Everything is fine. Customers are happy.

What each failure looks like

When the BRAIN is the problem, everything gets slower bit by bit. Requests queue up like customers waiting for one busy worker. The site isn't down - it's just crawling.

When the DESK is full, things crash suddenly. The computer starts throwing programs off the desk to make room, and it usually throws off the biggest one - which is often your database. One moment fine, next moment gone.

When the NOTEBOOK is the problem, you get the confusing case: the brain is bored, the desk has space, and yet everything is slow. Why? Every request is standing in line to read or write the notebook. This is the most common real-world bottleneck.

When the DOOR is the problem, answers just can't get out fast enough. This mostly happens when you're serving big things - photos, videos, downloads.

Remember these
  • Brain busy → everything slowly gets slower
  • Desk full → sudden crashes
  • Notebook busy → 'nothing is busy but everything is slow'
  • Door full → big files crawl
Words you just learned
bottleneck
- the ONE part that's full and making everything else wait

How far can one shop go?

Further than you'd think. Let's do the math with easy numbers. Say answering one request takes the brain 10 milliseconds (a millisecond is 1/1000 of a second). Then one brain core can answer 100 requests per second. A normal server has 8 cores, so roughly 800 requests per second - call it 500 to be safe.

500 per second is 43 MILLION requests a day. Most businesses on Earth never see that much traffic. So the honest first rule of system design: one good machine, not doing anything silly, goes incredibly far. People add ten machines to hide a problem that one machine could handle if the code stopped wasting its brain.

But one machine has one weakness that no amount of power fixes - and that's the next lesson.

Remember these
  • One decent server ≈ 500 requests/second ≈ 43 million/day
  • Before adding machines, ask: which of the four parts is actually full?
  • Fixing the wrong part changes nothing

Check your understanding

0/4 answered

Q1The website is slow, but the CPU (brain) is nearly idle and there's plenty of free RAM (desk). Which part is most likely the problem?

Q2A server has 8 cores, and each request needs about 20ms of thinking time. Roughly how many requests per second can it handle?

Q3Programs on the server suddenly start crashing with no warning. Which part most likely ran out?

Q4What should you always do BEFORE trying to fix a slow website?