Chapter Seven · Problem One
URL Shortener
The opening problem of the course, worked the way a 45-minute round runs: scope, a first design, the probes that scale it, and the deep dives.
"Design a service that turns a long URL into a short link and sends anyone who opens the short link to the original."
The interviewer reads the question in one sentence and stops. Everything else is yours to ask for: how many links, how long they live, whether anyone counts the clicks. The problem looks small, and that is the trap. A candidate who draws a table and a hash function in two minutes has nothing left for the forty that follow.
What it tests is a read path and a key space. Redirects outnumber new links by a wide margin, so most of the design is about answering the same lookups cheaply, which leans on the caching lessons of Chapter 2. Keys must never collide, and once the data no longer fits on one machine, handing them out without a single point of coordination leans on Chapter 3's partitioning and Chapter 5's IDs.
The problem suits a mid-level round, where a sound design with the right numbers is the bar. For a senior candidate it is a warm-up, judged on how fast they reach the hard parts: the hot link, the key generation, and the redirect code that decides whether clicks can be counted.
Before reading on, set a timer for 45 minutes and sketch your own answer. Ask yourself the questions an interviewer would expect, write down the numbers, and draw the first design. The four lessons follow the same clock, and they are worth more once you have your own version to compare.