Length 1:46Loading the video
Loading the video
How to design a service that turns long links into short ones and serves a million requests a second. Hand out numbers in blocks to make unique codes, split the data across machines, and serve popular links from fast memory.
Narrated by an AI voice.
A URL shortener turns a long link into a short one.
When someone opens the short link, the service sends them on to the long one.
Our target is one million requests a second.
Most of that traffic is people opening links.
Say ninety nine percent are reads.
That leaves ten thousand new links a second, or eight hundred sixty four million a day.
Each short link needs a unique code.
With letters and digits, there are sixty two choices per character.
Seven characters give about three and a half trillion codes.
That lasts eleven years at this rate.
To make codes without collisions, a counter service hands each app server a block of a million numbers.
The server turns its next number into a base sixty two code.
No database check is needed.
Each code and its long link go into a key value database.
The data is split into shards by code, so every lookup goes to one machine.
Reads must be fast.
A load balancer spreads requests over many app servers.
They ask a Redis cache first, because a small set of popular links gets most of the clicks.
Only a cache miss reaches the database.
The server answers with a redirect.
A 301 tells browsers to remember it, so repeat clicks skip the service.
A 302 brings every click back, so you can count them.
At this scale, a URL shortener is mostly a read problem.
Hand out numbers in blocks, shard the data by code, and serve popular links from a cache.
The system design interview: a repeatable approach
How system design interviews are run, and a five-step approach to repeat: requirements, rough numbers, API, data and scaling, with two worked examples.
Type any algorithm, interview problem or system, and get your own narrated video.
3 free videos with your own AI key. An AI key is a code from an AI company, such as Anthropic or OpenAI. Your own AI account pays for the writing. See pricing
Make a video
Length 1:46
Length 1:13
Length 2:20