CSE Roadmap

Common tier · about 4 hours · 7 parts

Part 7 of 7 · 2 min read

Exercises

Easy

Easy 1: Update rate (20 minutes)

4 million concurrent users, each sending a location every 20 seconds. Give the updates per second.

Done when: you write 200,000 per second.

Hint

4,000,000 / 20.

Easy 2: Forwarded messages (20 minutes)

Using 200,000 updates per second, 300 friends each, and 8 per cent online and nearby. Give the forwarded messages per second.

Done when: you write 200,000 × 24 = 4,800,000 per second.

Hint

300 × 8% = 24.

Easy 3: Cache size (20 minutes)

4 million active users, 100 bytes each. Give the size in MB.

Done when: you write 400 MB.

Hint

4,000,000 × 100 bytes.

Medium

Medium 1: Pub/sub servers (30 minutes)

With 4,800,000 pushes a second and 100,000 per server, give the number of servers. Add 30 per cent headroom.

Done when: you write 48 and about 63.

Hint

4,800,000 / 100,000, then × 1.3.

Medium 2: Channel memory (30 minutes)

50 million channels, 60 subscribers each, 20 bytes per subscriber. Give the memory in GB.

Done when: you write 60 GB.

Hint

50,000,000 × 60 × 20 bytes.

Medium 3: Walk the flow (30 minutes)

User A moves. Friends B (2 miles) and C (9 miles) are online. List the steps and say who receives the update.

Done when: a list of steps ending with B receiving it and C's handler dropping it.

Hint

The distance check is made by the receiver's handler.

Hard

Hard 1: Draw the design (60 minutes)

Draw the full design with all parts and number the update flow and the start-up flow.

Done when: a diagram with at least 8 parts and two numbered flows.

Hint

Draw the load balancer, two server types, cache, two databases and pub/sub.

Hard 2: Replace a server (60 minutes)

A pub/sub server dies. Write the steps from alert to full recovery, and say which updates are missed.

Done when: a timeline of steps with an estimate of the gap in seconds.

Hint

Only the dead server's channels move.

Hard 3: Add random people (60 minutes)

Design the "nearby random people" extension with grid-cell channels. Give the new fan-out, privacy controls and limits.

Done when: a design with cell size, channel naming, a fan-out estimate and three privacy controls.

Hint

A smaller cell means fewer people per channel.