Design a url shortener

Question

Step 1 - Understand the problem and establish design scope

Questions to ask

Back of the envelope estimation

TO CLARIFY

KB -> 1,000
MB -> 1,000,000
GB -> 1,000,000,000
TB -> 1,000,000,000,000

Step 2 - Propose high-level design and get buy-in

API Endpoints

POST api/v1/data/shorten
	- request parameter: {longURL: longURLString}
	- return shortURL
GET api/v1/shortUrl
	- Return longURL for HTTP redirection

URL redirecting

Hash function of 1 to 1 mapping

Step 3 - Design deep dive

Data model

Hash function

Collision

Base 62 conversion

URL shortening deep dive

CleanShot 2024-10-25 at 23.27.51@2x.png

URL redirecting infrastructure

CleanShot 2024-10-25 at 23.29.40@2x.png

Step 4 - Wrap up

Topics to discuss