Interview's MateSystem Design
Interview's Mate

System Design

Architecture & trade-offs

Visualizer

DSA Visualizer
All 32 lessons
Custom Playground
Try your own examples

Learning

System Design
31 architecture topics
SQL Learning
160 foundations → production topics
AI Engineering
160 LLM → backend topics
Data Science
160 Python → MLOps topics
Data Engineer
160 SQL → streaming topics
Docker
160 Docker learning topics
Kubernetes
160 K8s fundamentals → cloud
Java LearnSoon
Coming soon
Python Learn
Interview Q&A & internals
JavaScript Learn
Closures, async & DOM Q&A
Tech Learn
Search, practise & track Q&A
AI DSA Practice
Solve coding problems
Theme
Home
All topics/System Design Case Studies
RELIABILITY, SECURITY & CASE STUDIES · SUBTOPIC

Case Study: URL Shortener (TinyURL / bit.ly)

100:1 read-heavy redirection using Base62 IDs, Redis caching, and 301/302 trade-offs.

BeginnerPart of System Design Case Studies
Practice in AI HLD
Subtopics in System Design Case Studies (8)
OverviewURL ShortenerNews FeedChat AppUber / Ride-HailingYouTube / StreamingDropbox / DriveWeb CrawlerNotification System

In plain words

Save a map from a tiny 7-letter code like aB9x2Kq to the full long URL. Cache popular short links in Redis so redirects happen in 1 millisecond.

Think of it like…

A speed-dial number (*12) that dials a full 15-digit international phone number.

Loading interactive diagram
Loading interactive exercise

Theory & how it works

Why 7 Base62 characters (`[a-zA-Z0-9]`) is the sweet spot

62⁷ ≈ 3.52 trillion unique short codes. Even at 100 million new URLs created per day, 7 characters lasts 3.52 × 10¹² / 10⁸ ≈ 35,200 days (~96 years)! Generate unique counter IDs via a Ticket Server / Snowflake / Redis range allocator and Base62-encode them so collisions are zero.

301 vs. 302: 301 Moved Permanently lets browsers cache the redirect locally (cheapest for your servers, but breaks click-tracking analytics). 302 Found hits your server every click so you can log analytics accurately.

Key points & practical guide

Summary checklist

  • Base62 over unique distributed counter avoids collision retries
  • Cache hot short codes in Redis (~20 GB holds top daily traffic)
  • 302 for analytics tracking; 301 for maximum caching

When to use it

  • Classic beginner-friendly HLD warm-up problem

Watch out for

  • Doing synchronous analytics SQL writes on the redirect critical path - emit to Kafka instead

Quick check

Loading quiz
Parent topic
System Design Case Studies
Next subtopic
Case Study: Social News Feed (Twitter / Instagram)