Bugpit

Lessons › Big architectures

News site: every view counted

A news site gets 30,000 req/s on a big news day. Half are images. A third of the rest are page view events, and editors want a live "trending now" list and a full report every morning. Every event is written to the main database.

Play this level

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

The lesson

Analytics is the classic case of data that's written once and read in bulk later. It doesn't belong in the database that serves pages.

Send each view down an event stream. One reader keeps live counts, like the top stories over the last 10 minutes. That's a Stream Processor.

Another reader loads everything into a Data Warehouse, where analysts can run huge queries without slowing the site. Its data is a little behind, and that's fine for a report.

Images go on a CDN, as always. On a news day they're most of your traffic.

What you have to achieve

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

What you learn

The site now serves readers, editors and analysts, and none of them slows the others down. Watch the data warehouse line on the bill: storing every event forever adds up, which is why teams keep raw events for a while and summaries for longer.

Check yourself

Where should the morning report's huge queries run?

Show the answer

In a Data Warehouse. A warehouse is a little behind, and analysts can't slow the site down there.

What builds the live "trending now" list?

Show the answer

A Stream Processor counting views as they flow past. It keeps running counts over a window, like the last 10 minutes.

Try it yourself

More in Big architectures

← Smart home: a million devices Black Friday, worldwide →