← Back to problems

12. URL Shortener

MEDIUM
CACHERead-HeavyScalabilitySystem Design

Design a service that turns long URLs into short codes and redirects users from a short code back to the original URL at high read volume.

Design a URL shortening service (like bit.ly or tinyurl). Users submit a long URL and receive a short code; anyone who visits the short code is redirected to the original long URL. The system is extremely read-heavy: redirects vastly outnumber URL creations (assume on the order of 100:1 reads to writes). Redirects must be fast, because latency on the redirect path is user-visible on every click. The mapping from code to URL is effectively immutable once created, which you should exploit. You are designing the serving architecture: how requests enter the system, how the read (redirect) and write (shorten) paths are served, where the code-to-URL mapping is stored, and how you keep the hot read path fast under load. Lay out the architecture diagram, then document your API surface, your data storage choice, and the trade-offs you made.
Log in to submit a solution

Comments

Log into join the discussion.