Skip to content
Theory · URL shortener · lesson 5 of 10

Design step by step

The requirements and estimates are in hand: 40 new links and 4,000 redirects a second on average, 40,000 redirects at peak, and a 50 ms limit per redirect. Now let's build the design the way it is drawn in an interview: from the client to the data, one decision per step.

DiagramStep 1 of 4 · Two paths

There are 100 times more redirects than new links, so reads and writes go through different services. The redirect service keeps no state: under load you add copies of it.

Select a block to read its note

In an interview the order is the same: the request path first, then the data, then what carries the load. That way the interviewer sees where each block came from and can ask about any decision — for example, why codes come from a counter rather than at random.

Key points

  • Reads and writes go through different services: there are 100 times more redirects.
  • A cache in front of the store takes on the popular links.
  • Redirect counting goes to a queue and does not slow down the redirect.