CSE Roadmap

Core tier · about 4 hours · 8 parts

Part 8 of 8 · 2 min read

Exercises

Easy

Easy 1: Redo the reads (20 minutes)

A feed has 20 million DAU and each opens it 4 times a day. Give the average reads per second and a peak at 3 times the average.

Done when: you write about 926 per second and 2,778 per second.

Hint

80,000,000 / 86,400, then times 3.

Easy 2: Fanout writes (20 minutes)

3 million posts a day, 300 friends on average. Give the cache writes per day and per second under push.

Done when: you write 900,000,000 per day and about 10,417 per second.

Hint

Multiply posts by friends, then divide by 86,400.

Easy 3: Cache size (20 minutes)

10 million users, 800 ids each, 8 bytes per id. How big is the feed cache?

Done when: you write 10,000,000 × 800 × 8 = 64 GB.

Hint

10,000,000 × 800 = 8,000,000,000 ids.

Medium

Medium 1: Draw both flows (30 minutes)

Draw publishing and reading with every component named in this page, and number the steps of each flow.

Done when: two diagrams with at least eight labelled parts each.

Hint

The queue sits between the fanout service and the workers.

Medium 2: Celebrity burst (30 minutes)

An account with 2,000,000 followers posts. Workers write 25,000 entries per second. How long does push take, and what is the queue effect on normal posts?

Done when: you write 80 seconds and a note that normal jobs wait behind it.

Hint

2,000,000 / 25,000.

Medium 3: Read cost (30 minutes)

A reader follows 400 accounts, 5 of them above the threshold. Count lookups under pure push, pure pull and the hybrid.

Done when: you write 1, 400 and 6.

Hint

Push reads one list. Hybrid reads one list plus one per large account.

Hard

Hard 1: Choose the threshold (60 minutes)

Given a table of follower counts and posts per day for 10 accounts, choose a push or pull threshold. Show write cost and read cost for two values.

Done when: a table with both thresholds, costs for each account and a final choice with a reason.

Hint

Find the accounts where followers times posts is largest.

Hard 2: Add ranking (60 minutes)

Add a ranking step to the design. Say where scores come from, where they are stored and how a new post gets its first score.

Done when: an updated diagram and a short note on cold start and freshness.

Hint

A new post can start with a score from its author's closeness.

Hard 3: Mock interview (60 minutes)

Answer "design a news feed" aloud in 35 minutes and mark yourself on the four steps. List two missed topics.

Done when: a recording, a score on each step, and two named gaps.

Hint

Use the four-step framework as a checklist.