BLUEPRINT #05Core Infrastructure
Design a Distributed URL Shortener (TinyURL)
Referenced Architecture Primitives (5)
Click any primitive to study its algorithmic deep dive10-Stage Structure:1. Requirementsβ2. Sizingβ3. Topologyβ4. Data Modelβ5. AWS Topologyβ6. Deep-Diveβ7. Failuresβ8. SRE Playbooks
1. Problem Statement & Scope
System Mission
Design a highly scalable, fault-tolerant, low-latency URL Shortening service (similar to TinyURL or Bitly) that transforms long HTTP URLs into compact 7-character aliases, handles billions of redirects with sub-10ms latency, supports custom aliases, expiration TTLs, and real-time click analytics.
Functional Requirements
- URL Shortening (
POST /v1/urls): Given a long URL, generate a compact, unique 7-character alias (e.g.https://hi.link/aZ9k2Lq). - URL Redirection (
GET /{short_code}): Given a short code, instantly redirect the client to the original long URL with minimum latency. - Custom Aliases & Expiration: Allow users to specify custom short aliases (e.g.
https://hi.link/summit2026) and optional expiration timestamps (TTL). - Click Analytics: Asynchronously aggregate click metrics (total clicks, referrer, client country, timestamp).
Non-Functional Requirements (SLAs/SLOs)
- High Availability: uptime SLA for redirection lookups (Read Path is mission-critical).
- Ultra-Low Latency: P99 Read Redirection Latency ; P99 Write Latency .
- Durability: (11 9s) zero URL mapping loss guarantee.
- Read-to-Write Ratio: Heavy read bias of (100 redirections per 1 new URL shortened).
2. Capacity & Scale Estimation
Traffic Calculations
- New URL Creation Rate (Writes):
- 100 Million new URLs created per month.
- Average Write QPS:
- Peak Write QPS ( burst): .
- Redirection Traffic (Reads at 100:1 Ratio):
- Average Read QPS:
- Peak Read QPS ( burst): .
Storage & Memory Estimation (10-Year Horizon)
- 10-Year URL Volume:
- Record Size:
short_code: 7 Bytes.long_url: 500 Bytes average.user_id: 16 Bytes.created_at/expires_at: 16 Bytes.- Metadata & Overhead: 61 Bytes.
- Total per Record: .
- 10-Year Database Storage:
- 3-AZ Multi-Region Replicated Storage:
- In-Memory Cache Sizing (80/20 Pareto Rule):
- Daily active redirection requests: .
- hot URLs generate of traffic:
- Allocate an Amazon ElastiCache Redis Cluster with (easily caching 100% of daily hot URLs).
Base62 Encoding & Hash Space Math
A short code consisting of alphanumeric characters [0-9, a-z, A-Z] has a character alphabet size of:
For a 7-character string, the total unique URL capacity is:
At URLs/month, provides over 2,900 years of collision-free namespace capacity.
3. AWS-First High-Level Architecture
Interactive Architecture DiagramSynthesizing vector architecture diagram...
Part 2: Production Deep-Dive Locked1 Coin = 24 Hours
Unlock Complete Architecture & Production Runbooks
Your Balance:40 Coins
You have explored the free architectural preview (~42%). Spend 1 Coin to unlock the remaining 7 production deep-dive sections for a full 24 hours.
Sections Included in This 24-Hour Pass:
4. API Interface Design
5. Data Models & Storage Architecture
6. Component Deep Dives & Workflows
7. Architectural Trade-Off Matrix & Primitive Links
8. Critical Edge Cases & Distributed Failure Modes
9. Production Pitfalls & Anti-Patterns (The "Gotchas")
10. Production Runbook & Operational Best Practices
Keeps page unlocked for exactly 24 hoursSpend coins to fund LLM & compute infrastructure