bugl
bugl
HomeLearnPatternsPathsSearchPremium
HomeLearnPatternsPaths

Loading lesson path

Learn/System Design/Design a URL Shortener
System Design•Design a URL Shortener

Design a URL Shortener: Deep Dive

Design a service that turns long URLs into short links, redirects on access, and reports click counts.

How to approach it

Every system has one signature hard problem the interviewer wants to watch you reason about. Identify it, lay out two or three approaches with their tradeoffs, and recommend one with a clear justification. Depth on the core problem beats breadth across components.

Short-code generation

Generate unique, short, hard-to-guess codes at ~115 writes/s with no collisions.

Approaches

ApproachTradeoff
Hash(long URL) + truncatetruncation collides; needs check-and-retry
Random base62must check existence; rare retries at this scale
Counter + base62 (ranges per host)sequential/guessable but collision-free and fast

Tip

Recommended — Pre-allocate counter ranges per host, encode base62 (collision-free, no read-before-write); add a salt if guessability matters.

Previous

Design a URL Shortener: Scaling

Next

Design a URL Shortener: Tradeoffs & Review