Part 8 of 8 · 2 min read
Exercises
Easy
Easy 1: Connection memory (20 minutes)
20 million DAU, 10 per cent connected at peak, 10 KB per connection. How much memory, and how many servers at 40,000 connections each?
Done when: you write 2,000,000 connections, 20 GB, and 50 servers.
Hint
20,000,000 × 10% is 2,000,000 connections.
Easy 2: Message rate (20 minutes)
20 million DAU send 30 messages a day each. Give messages per day and per second.
Done when: you write 600,000,000 a day and about 6,944 per second.
Hint
20,000,000 × 30 = 600,000,000.
Easy 3: Heartbeats (20 minutes)
3 million users online, one heartbeat every 10 seconds. How many per second?
Done when: you write 300,000 per second.
Hint
Users divided by seconds between beats.
Medium
Medium 1: Draw the one-to-one flow (30 minutes)
Draw the six steps with both chat servers, the ID generator, the queue, the store and the push servers. Show the online and offline branches.
Done when: a diagram with numbered steps and both branches.
Hint
Step 5 splits into two branches.
Medium 2: Group copies (30 minutes)
A group of 100 sends 50 messages a minute. How many inbox copies are made per hour?
Done when: you write 50 × 60 × 99 = 297,000.
Hint
Each message goes to 99 other members.
Medium 3: Sync a device (30 minutes)
A tablet last saw id 1,200. The store has ids up to 1,260 for this user, but 15 of them in that range belong to other users. How many messages does the tablet fetch?
Done when: you write 60 ids in range, minus 15, which is 45 messages.
Hint
Ids 1,201 to 1,260 is 60 ids.
Hard
Hard 1: Large groups (60 minutes)
Redesign group delivery for groups of 50,000. Say how messages are stored, how members read, and how push notifications avoid a storm.
Done when: a design with a single stored copy, per-member read positions and a push rule such as batching or muting.
Hint
Think of a shared log with a read position for each member.
Hard 2: Presence at scale (60 minutes)
Cut the heartbeat load for 20 million online users. Compare longer intervals, batching and sending heartbeats only when idle.
Done when: a table with load for each option and the cost in detection time.
Hint
A longer interval cuts load but delays the offline mark.
Hard 3: Mock interview (60 minutes)
Answer "design a chat system" 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.