Every case study in five lines
Each of the 30 case studies on this site is a 45-minute mock interview of about twelve pages. This page gives each one in five lines, so that in the week before a round you can recall the shape of every question without rereading it. The five lines are always the same. The ask is what the interviewer wants and the names the question goes by. The numbers are the figures that decide the design. The design is the boxes in the order the data flows, in one sentence. The deep dives are that page's Step 6 deep dives in order, with the pattern each one applies, and anything from the staff extension or the "Next" line is labelled as such. The trap is the mistake from that page's "Mistakes that cost offers" that most candidates make.
Every figure is copied from the case study's own 2-minute answer or cheat sheet, and each heading links that page. Read all 30 once, mark the ones closest to what your company asks (How the round differs by company), and reread those in full.
Case studies: the classics
URL shortener (like Bitly)
- The ask. Turn a long address into a short one and redirect every click, also asked as "design TinyURL".
- The numbers. 40 writes a second on average, and 4,000 redirects a second on average, 10,000 at peak, about half a replica's ~20,000.
- The design. Servers shuffle counter blocks into 7 base62 characters, and Redis or a replica answers each click with a 302.
- The deep dives. Generating short codes, then the redirect at scale at 95% hits, then counting clicks off the hot path. They apply Scaling reads and Counting at scale.
- The trap. Do not answer a plain 301, because browsers keep it and a disabled link keeps working.
Rate limiter
- The ask. Refuse a caller's extra calls fast, also asked as "design a distributed rate limiter".
- The numbers. 50,000 calls a second at peak, each counted against two limits, so 100,000 counter updates a second inside 5 ms.
- The design. A library in each gateway runs one Lua script per call on one of three Redis primaries.
- The deep dives. Counting two limits in one step, then Redis slow or gone, when each gateway allows its share for about 15 seconds. They apply Rate limiting algorithms, and three regions is the staff extension (Going multi-region).
- The trap. Do not make two separate increments, because a refused call then spends the user's quota.
Notification system
- The ask. Deliver what services want to tell people by push, email, SMS or an inbox, also asked as "design a push notification service".
- The numbers. 2,500 a second on average and 7,500 at the evening peak, while a 9:00 campaign adds ~11,000 a second. A sign-in code reaches the provider within 2 seconds at p99.
- The design. One API writes a row per notification on twelve shards, and senders on two lanes claim rows and call providers.
- The deep dives. Sending each notification once, then the 9:00 campaign without delaying a sign-in code, on separate lanes. They apply Scheduling work for later and Idempotency and deduplication, and home regions are the staff extension.
- The trap. Do not put sign-in codes and campaigns on one queue, because a code then waits about 4 minutes.