Bugpit

Lessons › From one user to millions

CDN, queues and no single point of failure

30,000 req/s. Half are images and scripts, and writes trigger slow work like emails. Nothing may go down if one machine dies.

Play this level

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

The lesson

A CDN serves static files from servers near the user. Those requests never reach your data centre, and users get them in ~10 ms (§7.4). It saves servers and time, but it isn't free: you pay for every request and GB.

A Queue lets the app answer right away and hand slow work to Workers in the background. Add enough workers or the backlog keeps growing (§9).

A single point of failure (SPOF) is any component that takes the whole system down when it dies. Run at least 2 of each, and give the database a standby (§10.2).

What you have to achieve

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

What you learn

This is the classic Stage 4 architecture. Open "A day of traffic" to see the queue fill at the evening peak and empty overnight, which is why you need fewer workers than the peak suggests.

Check yourself

Sending an email after a write was slow. What fixed it?

Show the answer

A queue and workers in the background. The app answers straight away and hands the slow work to workers. You need enough workers or the backlog grows.

What is a single point of failure?

Show the answer

A part that takes everything down when it dies. Run at least 2 of each part, and give the database a standby, so no one machine can take the system down.

Try it yourself

More in From one user to millions

← Add a cache Move files off your servers →