Bugpit

Lessons › Core concepts

How a request travels

You launch shop.example to 5,000 req/s. Nobody can find it by name yet, and half of every page is images and scripts that your two servers send again and again.

Play this level

Free with an account. It runs in your browser: build the design, press Run, and watch what breaks.

The lesson

A request makes several trips before your code runs. The browser asks DNS for the address, opens a connection, agrees encryption with TLS, and only then sends the request.

Latency is how long one request takes. Throughput is how many requests you finish each second. More servers raise throughput, and do nothing for the time of a single request.

Every trip costs time that grows with distance, so the fastest request is the one that never travels far. A CDN answers images and scripts from a city near the user.

What you have to achieve

5,000 requests a second at the busiest hour, 5% of them writes and 50% static files.

What you learn

You followed one request from a name to an answer. DNS made you findable, and the CDN took the files off your servers, which raised throughput and cut the wait for everyone far away.

Check yourself

What happens first when someone types shop.example into a browser?

Show the answer

DNS turns the name into an address. Nothing can be sent until the browser knows where to send it, and DNS gives it the address. Browsers then cache the answer for a while.

Each request takes 80 ms. You double the servers. What happens?

Show the answer

You can answer about twice as many requests a second. More servers raise throughput, the number answered each second. One request still does the same work, so its latency stays about the same.

Users in Sydney wait 300 ms for a server in Virginia. What helps most?

Show the answer

A CDN with copies near Sydney. Distance costs time on every trip, and a bigger machine can't make light travel faster. Serving the files from nearby removes the long trip.

Try it yourself

More in Core concepts

← Payouts: every cent accounted for Forget the user between requests →