Problem
Design a service that creates short links and redirects them to their original URLs. Discuss uniqueness, storage, traffic, caching and failure behaviour.
Worked examples
Input: POST /links with a long URL; GET /abc123
Output: A short link, then a redirect to the stored URL
The mapping must survive a process restart.
Hints
Hint 1
Separate creating a mapping from reading it.
Hint 2
Ask whether custom aliases and expiry are required.
Solution approach
- Define redirect latency, expected read/write volume and link lifetime before drawing services.
- Choose an ID/encoding strategy with collision handling and a unique database constraint.
- Describe cache-aside reads, durable storage, invalidation and abuse controls.
- Explain where eventual consistency is acceptable and how expired or missing links behave.
Complexity
Discuss throughput, storage growth, cache hit rate and redirect latency; there is no single algorithmic complexity target.
Report & practice notes
Restated practice version with original examples and explanation. The source is a candidate account, not an official question paper; assessment details can vary. Difficulty is our editorial estimate.
Read the candidate’s source report ↗