πŸ’¬
βœ‰οΈ
πŸ“Έ
▢️

Loading…

Design a URL Shortener (TinyURL): Interactive System Design

URL ShortenerGuided Mode

πŸ”—

short.ly/abc123 β†’

https://verylongdomain.com/very/long/path?with=params

What is a URL Shortener?

URLs can be hundreds of characters long β€” ugly, untrackable, and impossible to share in SMS or tweet limits.

A URL shortener maps a long URL to a short code, stores the mapping, and transparently redirects visitors.

Request Flow

1

User shortens a URL

POST /shorten with the long URL β†’ API generates a short code β†’ returns https://short.ly/abc123

POST /shorten
{ "url": "https://verylongdomain.com/article?id=12345" }

β†’ 201 Created
{ "short_url": "https://short.ly/abc123" }
2

Someone clicks the short link

Browser visits https://short.ly/abc123 β†’ GET /abc123 β†’ server looks up the code β†’ returns 302 redirect β†’ browser follows to original URL

GET /abc123

β†’ 302 Found
Location: https://verylongdomain.com/article?id=12345

Why We Need This

The architecture challenge is not the shortening β€” it is the redirect performance.

For every 1 URL created, it might be clicked 10,000 times. The GET /:code path must handle millions of reads per second, under 50ms.

Key Insight

The core challenge: generate unique short codes, handle 100:1 read/write ratio, and redirect millions of lookups per second β€” all under 50ms.

Overview