Lesson 14 of 15
31. Design a URL Shortener

Sources

3 min read+10 XP

Source notes

  • 301 (Moved Permanently) responses are cacheable by default; 302 (Found) only with explicit freshness information; 307 and 308 keep the request method: HTTP Semantics, RFC 9110, sections 15.4.2, 15.4.3, 15.4.8 and 15.4.9.
  • All traffic numbers are interview assumptions agreed in Step 1, not figures for any real service.
  • Arithmetic (62⁶ = 56,800,235,584; 62⁷ = 3,521,614,606,208; about 333 million redirects a day; about 33 GB of hot cache; 6 billion ÷ 62⁷ ≈ 0.17% clash chance per new random code at full size) computed 2026-10-05.
  • ID blocks, scrambling and hash-with-retry code: tested 2026-10-05 (code/ch31_url_shortener.py, all checks pass).