Bugpit

Lessons › Big architectures

Black Friday, worldwide

A shop with customers in America, Europe and Asia. On Black Friday 30,000 req/s arrive, half of them images, and everything runs in one region in Virginia. The board has one question: what happens if that region goes dark mid-sale?

Play this level

Part of Bugpit Pro. It runs in your browser: build the design, press Run, and watch what breaks.

The lesson

Start with distance. Run the app in three regions, close to each group of customers, with a cache in each so product pages stay local.

A crowd this size needs a waiting room in front, set to what your servers can really take. Nobody gets an error, they wait a moment instead.

Orders are the only writes, and there's only one primary. Put them in a queue so a customer in Tokyo isn't waiting on Virginia, and let workers save them.

Then the big one: a whole region failing. Each region needs enough servers to cover for a lost one, and a replica somewhere else that can become the primary.

What you have to achieve

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

What you learn

Lose Virginia mid-sale and the other two regions carry on. Look at the bill, though: you're paying for a third more servers than a normal day needs, just in case. Running in several regions is insurance, and like any insurance, someone has to decide it's worth it.

Check yourself

Why do orders go through a queue in a worldwide shop?

Show the answer

There's one primary, and nobody should wait on a database across the world. The order is taken locally and saved in the background.

With 3 regions, how many servers must each region have?

Show the answer

Enough to cover for a lost region. If one region goes dark, the other two carry everyone. That spare capacity is the price of the insurance.

Try it yourself

More in Big architectures

← News site: every view counted Watch next: a row for every person →