CSE Roadmap

Core tier · about 4 hours · 8 parts

Part 8 of 8 · 2 min read

Exercises

Easy

Easy 1: Redo the load (20 minutes)

A system sends 30 million push, 3 million SMS and 12 million emails a day, with peaks of 4 times average. Give peak per second for each channel.

Done when: you write 1,389, 139 and 556 per second.

Hint

30,000,000 / 86,400 is about 347 per second average, times 4.

Easy 2: Little's law (20 minutes)

Using the peaks from Easy 1 and call times of 200 ms, 400 ms and 250 ms, give the concurrent calls for each.

Done when: you write about 278, 56 and 139.

Hint

Concurrent calls equal rate times seconds per call.

Easy 3: Drain time (20 minutes)

A queue holds 6 million emails and workers send 800 per second. How long does it take to empty, and how long if 1,200 per second?

Done when: you write 7,500 seconds (about 2 hours 5 minutes) and 5,000 seconds (about 1 hour 23 minutes).

Hint

Divide 6,000,000 by the sending rate.

Medium

Medium 1: Draw the system (30 minutes)

Draw the improved design with services, servers, cache, database, four queues, workers, providers and the log. Number the six flow steps.

Done when: a diagram with at least ten labelled parts and numbered steps.

Hint

The cache and database sit beside the notification servers.

Medium 2: Retry load (30 minutes)

With a failure rate of 8 per cent at first try and 8 per cent again at each retry, up to 3 retries, give the expected number of provider calls per 1,000 messages.

Done when: you write 1,000 + 80 + 6.4 + 0.5, about 1,087 calls.

Hint

Each stage multiplies by 0.08.

Medium 3: Dedupe window (30 minutes)

Events arrive at 400 per second. The retry window is 2 hours. Size the dedupe set for 16-byte ids and choose how long to keep entries.

Done when: you write 400 × 7,200 × 16 bytes = 46 MB for 2 hours, and a reason for a longer keep time.

Hint

400 per second for 7,200 seconds is 2,880,000 ids.

Hard

Hard 1: Priority design (60 minutes)

Design priority lanes for reset codes, order updates and marketing. Give queues, worker shares, the starvation rule for marketing and the alarms.

Done when: a table with three lanes, worker counts, a rule that stops starvation, and alarm thresholds.

Hint

Marketing needs a small guaranteed share so it is never stuck forever.

Hard 2: Provider failover (60 minutes)

Design failover between two SMS providers with a circuit breaker. State what opens it, how it half-opens, and what happens to queued messages.

Done when: a state diagram with thresholds and a rule for messages in flight.

Hint

A breaker half-opens by letting a few test calls through.

Hard 3: Mock interview (60 minutes)

Answer "design a notification 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.