Wirebook › Lesson 3 of 18
Can a website get tired?
Websites don't get sleepy, but they can get overwhelmed. A server can only do so much work each second. When more people arrive than it can handle, they start to queue, and if the queue grows forever, things break. Here's how that works, and how sites stay calm.
Why queues explode
If a server answers 10 requests a second and 8 arrive, it's fine: there's spare time. At 9.5 it's still coping, but every small burst makes people wait a bit longer. At 10.5 the line grows by half a person every second forever. Wait times don't creep up gently; they shoot up as you get close to 100% busy. Engineers try to keep servers well below full for exactly this reason.
Four ways websites stay calm
- Caching: remember answers. If a thousand people ask for the same page, work it out once and hand out copies.
- Rate limits: politely tell anyone asking too often to slow down (that's the
429 Too Many Requestscode). Better a quick "not now" for a few than a crash for everyone. - More servers: share the work across several computers, with a load balancer deciding who gets each request.
- Do less work: small pages, no heavy tracking scripts, and doing jobs in the browser instead of on the server. The free tools on this server work that way, which is why one tiny computer can serve lots of people.
Grown-up twin: when a site is overloaded or a middleman gives up waiting, see Tooltern’s HTTP 503 Service Unavailable, HTTP 504 Gateway Timeout, 502 Bad Gateway, and HTTP 429 Too Many Requests guides. Anvil’s HTTP status helpers name the codes.