High-ThroughputMid Level

High-Scale URL Shortener & Key Generation

Design a globally distributed TinyURL service with 100:1 read-heavy traffic and sub-10ms redirects.

Target Scale

Engineering Scale & Performance SLAs

Target production parameters expected in a senior or staff interview round.

Peak Throughput

115,000 Read QPS / 1,150 Write QPS

Sustained peak request volume during high-traffic events.

Active Users

100 Million Active Links

Daily active users generating read and write operations.

Storage Ingestion

15 TB storage / 5 years

Projected data ingestion and replication storage capacity.

Latency Budget

Redirect < 10ms

Strict end-to-end percentile latency SLA constraint.

Stage 01

Functional & Non-Functional Requirements

Establish clear problem boundaries before proposing architectural components.

Functional Scope

Core System Capabilities

  • Generate unique 7-character short URLs from arbitrary long destination URLs.
  • Redirect short URLs to original URLs with HTTP 301/302 redirects.
  • Support custom alias short links and expiration TTLs.
Non-Functional Scope

Reliability & Latency SLAs

  • High availability (99.999% uptime) with zero downtime deployments.
  • Ultra-low redirect latency (p99 < 10ms).
  • Collision-free unique key generation.
Stage 02

Capacity Estimation Math

Step-by-step arithmetic conversions for QPS, storage, and bandwidth.

DimensionCalculation FormulaEstimated Result
Write & Read Throughput100M new URLs/month = ~40 write QPS. 100:1 read ratio = ~4,000 read QPS (Peak = ~115k QPS)~1,150 Peak Write QPS / ~115,000 Peak Read QPS
5-Year Storage Capacity100M URLs/month × 12 months × 5 years × 500 bytes/record~30 Billion URLs = ~15 Terabytes total persistence
Cache Memory Size20% hot URLs account for 80% read traffic. 115k QPS × 86,400s × 0.2 × 500B~100 GB RAM Redis Cache Cluster
Stage 03

Multi-Tier Architecture & Component Topology

How requests navigate ingress gateways, application logic, caching, and persistence.

Key Generation Cluster (KGS)

Dedicated Key Gen Service · Zookeeper / Etcd Coordinator

Pre-generates Base62 7-character keys into memory buffers, avoiding on-the-fly hash collisions.

Web & API Gateway Tier

Nginx / Envoy Load Balancer · Go / Rust Stateless Redirect Service

Handles short code lookups from cache, returning immediate HTTP 301 redirects.

Persistence & Cache Tier

Redis LRU Cache · Cassandra / DynamoDB Distributed Store

Stores key-to-URL mappings sharded by the first 2 characters of the short key.

Stage 04

Database Schemas & Partitioning Strategy

Entity models, indexing, and primary key partitioning.

Table: url_mappings

PK: short_key

  • short_key (VARCHAR, PK)
  • original_url (VARCHAR)
  • user_id (VARCHAR)
  • created_at (TIMESTAMP)
  • expires_at (TIMESTAMP)

Partitioned by short_key hash with secondary index on user_id for analytics.

Stage 05

Critical Architectural Trade-Offs

How to defend engineering compromises when challenged by interviewers.

Decision Point

HTTP 301 vs HTTP 302 Redirect

Option A: 301 Permanent Redirect (Browser caches, reduces server load)
Option B: 302 Temporary Redirect (Server intercepts every click, tracks analytics)

Rationale: Selected 302 for commercial analytics and link revocation, with edge CDN caching to balance latency.

Decision Point

MD5/SHA256 Hashing vs Key Generation Service (KGS)

Option A: Hash + Base62 Encoding (Requires collision resolution loops)
Option B: Stand-alone Key Generation Service (Pre-generates unique sequential keys)

Rationale: KGS eliminates duplicate hash retries and guarantees O(1) instantaneous write latency.

Technical FAQ

Frequently Asked Questions: High-Scale URL Shortener & Key Generation

Key interview questions and conceptual defenses.

Why use Base62 encoding for short URLs?

Base62 uses [a-z, A-Z, 0-9]. A 7-character string provides 62^7 = 3.5 trillion unique URLs, easily sufficient for decades of scale.

Simulate this architecture

Practice High-Scale URL Shortener & Key Generation with ClawPad's interactive diagram overlay.

Download ClawPad