SystemDesignDraw Logo
SystemDesignDraw

Architecture Whiteboard & Math

Beginner FriendlyBeginner Difficulty6 min read

Design a URL Shortener (TinyURL / Bitly)

A URL shortener converts a long link (like a 100-character article URL) into a compact 7-character key (like tinyurl.com/xyz123) and redirects visitors in under 15 milliseconds.

Estimated Traffic4,000 Reads/sec • 40 Writes/sec
5-Year Data Footprint15 Terabytes
Target Latency< 15 milliseconds
Availability Target99.99% (4 Nines)
Need custom numbers for your interview?Calculate QPS & capacity in System Design Cheat Sheet →

Live Architecture Studio

Edit components, modify labels, add databases, or redraw connections directly on this canvas:

Browse Component Stencils & Icons →
Blueprint:TinyURL Shortener
ZenResetExportFull

Loading TinyURL Shortener Blueprint...

Mounting vector diagram elements, nodes, and capacity metrics

Mounting TinyURL Shortener...
Loading
Topology Nodes (8) Interactive Canvas
⚡ Interactive Architecture Diagram • Drag & Drop Enabled

1. Problem & Challenge

Millions of users paste long links and want immediate short URLs. When anyone clicks that short link, the system must instantly look up the destination and redirect them without crashing or mixing up links.

2. Core Building Blocks & Responsibilities

👉 Desliza la tabla para ver roles y responsabilidades
ComponentRolePlain-English Explanation
DNS & CDN EdgeTraffic EntryRoutes visitors to the closest server geographically so redirection happens with near-zero network delay.
Load Balancer (ALB)Traffic DirectorDistributes millions of requests evenly across web servers so no single server gets overwhelmed.
Key Generation Service (KGS)Unique ID CreatorPre-generates random 7-character Base62 codes (like a-z, A-Z, 0-9) ahead of time so creating a new URL never has collisions.
Redis Cache LayerUltra-Fast MemoryStores the top 20% most-clicked links directly in RAM so 80% of redirects don’t even touch the main database.
Sharded SQL DatabasePermanent VaultStores the permanent mapping: Short Hash -> Long URL. Sharded by the first character of the hash.

3. Step-by-Step Request Flow

1

User Pastes Long URL

The client sends a POST request with the long destination link to the API Gateway.

2

Grab Pre-Made Key

Instead of calculating slow MD5 hashes on the fly, the server asks the Key Generation Service for the next available 7-char code.

3

Save to DB & Cache

The mapping is saved in the database, copied into Redis, and the short link is returned to the user in 10ms.

4

Visitor Clicks Short Link

The visitor’s browser requests the short link. The server checks Redis first. If found, it returns an HTTP 302 redirect instantly.

4. Architectural Trade-offs

Decision:

HTTP 301 vs HTTP 302

Chosen: HTTP 302 (Temporary Redirect)

Rationale: 301 is permanently cached by browsers, which stops you from tracking click analytics and link expiration.

Decision:

Hash on the fly vs Pre-generated Keys

Chosen: Pre-generated KGS

Rationale: Hashing strings often leads to duplicate collisions. Pre-generating unique keys guarantees zero collisions.

Interview Tip

Always mention the 80/20 Pareto principle: 20% of short links will generate 80% of click traffic. Caching that 20% in Redis prevents database bottlenecks.

Distributed Architectures

Explore Related System Blueprints

View All Blueprints (13) →
Interview Favorite7 min read

API Rate Limiter

A rate limiter acts as a digital bouncer at the door of your API, ensuring each client stays within their allowed request limits (e.g. 100 requests per minute) and blocking abusive traffic.

Study Architecture →
Streaming & Media9 min read

Video Streaming CDN

Streaming high-definition video to millions of smart TVs and mobile phones requires breaking large 10GB video files into tiny 5-second chunks, encoding each into 20 different resolutions, and caching them right inside local ISP networks.

Study Architecture →
Real-Time & Geo10 min read

Uber Dispatch Engine

A real-time geospatial dispatch system matches riders with the most optimal nearby drivers using 64-bit H3 hexagonal indexing and 2-second batch optimization, minimizing city-wide pickup ETA and driver idle time.

Study Architecture →
Fintech & Ledger11 min read

Stripe Payments Ledger

A resilient financial payments architecture guarantees strict consistency (CP system) using cryptographic idempotency reservation, double-entry balanced postings, and sharded balance locks.

Study Architecture →
Real-Time & Collab9 min read

Figma Multiplayer Engine

A real-time multiplayer document engine uses stateful sticky session routing and server-authoritative operational ordering to sync 2D scene graphs across worldwide collaborators without locking.

Study Architecture →
Feed & Distributed8 min read

Twitter Timeline & Feed

A timeline generation system balances high write amplification against fast sub-50ms reads by pushing tweets to followers of regular accounts, while pulling and merging celebrity tweets on-demand.

Study Architecture →