Skip to content
Preptima
hardDesignCase StudyMidSeniorStaff

Design a URL shortener.

6 min readUpdated 2026-08-15

Answer

Short answer

2k writes/s and 116k redirects/s, needing 7-character base62 keys. Generate keys from leased counter blocks scrambled by a bijection, serve reads from cache and CDN, and redirect with 302 rather than 301.

Was this answer helpful?

Likely follow-ups

  • How do you support user-chosen custom aliases without breaking the generated keyspace?
  • A single link goes viral and takes 40% of all traffic. What breaks first, and what do you change?
  • How would you implement per-link click analytics without putting a write on the redirect path?
  • What has to be true for you to safely delete expired links, and why is reusing their codes dangerous?

Related questions

Further reading