URL Shortener
A small system with real decisions: how to generate short codes, which redirect status to return, how to serve heavy reads, and how to stop abuse. A good first full design.
Lessons
- 01Define the promise and estimate demandA tiny link hides a read-heavy system with a durable mapping.
- 02Design creation and lookup togetherThe creation response must leave a durable mapping for every later redirect.
- 03Choose redirect and expiry semanticsHTTP status codes determine who sees future clicks and how failures appear.
- 04Generate keys without collisionsThe key-space must fit demand, and concurrent creation must preserve uniqueness.
- 05Make the read path cheapMost traffic resolves existing keys, so optimize lookup without making cache the source of truth.
- 06Plan for failure and misuseA redirect service must remain trustworthy when dependencies fail or attackers create links.