Try
↑ ↓ move↵ openesc close

Interview prep / URL shortener

Junior · URL shortener · System design interview question

What does a URL shortener do, and what are its two main operations?

Sketch your own answer first, then compare it with the one below.

A strong answer

It maps a short code to a long address. The two operations are create, which takes a long address and returns a code, and redirect, which takes a code and sends the user to the long address.

The store behind it is a key-value table keyed by code. Reads far outnumber writes, so a good answer says so early and plans a cache.

Sources

Learn it by running it

The design a url shortener lesson explains the mechanism behind this question, and its lab lets you change the parameters and watch the effect.

Your progress is saved in this browser. Sign in to keep it on every device. Privacy · Terms