Skip to main content
← PROBLEMS / SYSTEM-DESIGN
An end-to-end domain learning journey

Design a Global URL
Redirection Engine (100K RPS).

Design a globally distributed URL shortening and redirection engine serving 100K RPS reads (<15ms p99), 1K RPS writes, 5-year durability, and real-time click analytics.
Start the journey7 stages· Last modified Nov 24, 2026
FIRST PRINCIPLES. PRODUCTION SCALE.
The idea to keep with you

If latency budgets leave no room for synchronous retries, serve redirects from Anycast Edge POPs with L1 LRU + regional Redis, coordinate writes via pre-allocated Base62 key-range shards, and replicate asynchronously across regions.

TL;DR30-second simplified summary
▾

Anycast Edge POPs pair L1 in-memory LRU caches with regional Redis Clusters to serve 98% of 100K RPS reads locally in <15ms. Multi-region write coordinators lease disjoint Base62 prefix shards ([a-g]*, [h-n]*, [o-z]*) so regions write locally with zero WAN locks.

Active-active Cassandra/DynamoDB replicates globally, with origin-encoded prefixes enabling single-hop fallback on fresh misses and Pub/Sub purges enforcing phishing takedowns in seconds.

Before you begin · Building blocksAlready know these? Jump to Stage 01 ↓
Base62 URL Shortening & Edge Redirection
Base62 URL shortening maps 64-bit distributed counter IDs into compact 7-character alphanumeric codes (62^7 = 3.52T combinations), pairing collision-free writes with edge-cached HTTP 301/302 redirection.
Full walkthrough · 7 stages
01
foundation

Traffic & 5-Year Storage Sizing.

Why this matters: Calculate read/write QPS, 5-year storage footprint, and Redis cache memory.

1K writes/sec * 86,400s * 365d * 5y = ~157.7B URLs.

At ~500 bytes per record (short_code, long_url, user_id, created_at, expires_at), raw data is ~79TB (with 3x replication = ~237TB).

Stage 1 - Capacity Math

100K RPS & 5-Year Storage Model

1K RPS Writessource79 TB Raw / 237 TBRepstorage100K RPS Readsprocessor8.5 GB Hot Cachecache80/20 working set

1.7-Char Base62: 62^7 = 3.52T easily covers 158B URLs (<5% utilization over 5 years).

2.Bandwidth: 100K RPS * 500B redirect response = ~50 MB/s (400 Mbps) aggregate egress.

79TB of 5-year data and an 8.5GB hot working set dictate NoSQL sharding plus regional Redis.

02
foundation

Anycast Edge POPs & L1/L2 Regional Caching.

Why this matters: Achieve <15ms global p99 redirect latency across continents.

Anycast BGP routes users to the nearest Edge POP.

Each POP maintains an L1 in-memory LRU cache (100K hottest global slugs, <0.2ms) and queries a regional L2 Redis Cluster (<2ms) on L1 miss.

Stage 2 - Global Edge

Anycast POP + L1/L2 Cache Hierarchy

Global User ClicksourceEdge POP L1 LRUcacheRegional L2 RedisprocessorLocal NoSQL ReplicastorageMiss -> Regional Redis

1.Viral Absorption: L1 LRU absorbs 50K+ RPS single-link spikes without hitting Redis.

2.Negative Cache: Edge Bloom filters + 60s 404 cache block invalid-code floods.

Three-tier Anycast + L1 + L2 caching keeps 98% of redirects within the local metro region.

Engineering Decision Framework
Problem
How to implement Design a Global URL Redirection Engine (100K RPS) without hitting unbounded tail latency, state divergence, or operational fragility.
Naive Solution
Use a single unpartitioned path with unbounded retries and synchronous global coordination.
Why It Fails
Global coordination serializes throughput under load, while unbounded retries amplify transient stalls into full outages.
Alternatives
Compare synchronous strict-consistency paths against bounded asynchronous replication, local caching, or partitioned ownership.
Engineering Decision
If latency budgets leave no room for synchronous retries, serve redirects from Anycast Edge POPs with L1 LRU + regional Redis, coordinate writes via pre-allocated Base62 key-range shards, and replicate asynchronously across regions.
Trade-Offs
Gains predictable p99 latency and fault isolation in exchange for explicit bounding, observability, and slightly higher implementation complexity.
Decision Exercise · Make the Call

When Design a Global URL Redirection Engine (100K RPS) experiences a sudden 5x traffic spike alongside a slow downstream dependency, which engineering choice best protects system stability?

03
intermediate

Multi-Region Write Coordinator & Key-Range Shards.

Why this matters: Generate globally unique short codes across US, EU, and APAC with zero cross-region locks.

Think of Multi-Region Write Coordinator & Key-Range Shards as the intuition layer for Design a Global URL Redirection Engine (100K RPS): Generate globally unique short codes across US, EU, and APAC with zero cross-region locks.

Running cross-continent Paxos on every POST /shorten would add 150ms+ write latency. Instead, a central ZooKeeper/etcd coordinator assigns disjoint prefix ranges to each region (e.g., a-g* to US, h-n* to EU, o-z* to APAC), and regional write workers lease 1M-ID sub-blocks locally—generating globally unique codes in <1ms.

Stage 3 - Multi-Region Writes

Disjoint Regional Key-Range Shards

Global Range LeasestorageUS Write PoolprocessorEU Write PoolprocessorAPAC Write PoolprocessorLease EU shard

1.Zero Cross-WAN Write: Regions issue short codes completely independently with zero WAN round-trips.

2.Custom Vanity Slugs: Only user-chosen custom aliases use conditional quorum writes (LWT/ConditionalPut).

Disjoint regional key-range shards eliminate cross-region consensus from the standard write path.

04
intermediate

Active-Active Geo-Replicated NoSQL & Read-Your-Writes.

Why this matters: Replicate mappings globally while ensuring a creator's immediate test click never 404s.

Think of Active-Active Geo-Replicated NoSQL & Read-Your-Writes as the intuition layer for Design a Global URL Redirection Engine (100K RPS): Replicate mappings globally while ensuring a creator's immediate test click never 404s.

Cassandra (NetworkTopologyStrategy) or DynamoDB Global Tables replicates writes asynchronously across regions in ~1-2s. To prevent a creator from hitting a 404 if they click their new link within 200ms in a different POP, the write response sets a short-lived regional affinity hint (or writes-through to the creator's local L2 Redis) and cold misses fall back cross-region once before returning 404.

Stage 4 - Geo-Replication

Active-Active NoSQL + Cross-Region Fallback

US Write WorkersourceAsyncGeo-ReplicationprocessorEU Cold Missrouter1x Origin FallbacksinkVerify miss if fresh

1.First-Char Hint: The slug's first character encodes its origin region, making 1x fallback routing exact.

2.Bounded Fallback: Only fall back for keys passing the Bloom filter or within 10s of creation.

Encoding origin region in the prefix enables exact single-hop fallback during replication lag.

05
intermediate

Safe-Browsing Phishing Scanner & Abuse Takedown.

Why this matters: Block malicious destinations at creation time and propagate takedowns globally in seconds.

Think of Safe-Browsing Phishing Scanner & Abuse Takedown as the intuition layer for Design a Global URL Redirection Engine (100K RPS): Block malicious destinations at creation time and propagate takedowns globally in seconds.

On POST /shorten, the Write Worker checks the destination domain/URL against an in-memory Safe-Browsing prefix hash list (<1ms) and rejects known malware/phishing with 400 Bad Request. An async crawler inspects newly created links for redirect chains/phishing kits; confirmed abusers trigger a Redis Pub/Sub cache invalidation across all Edge POPs and mark the DB row BANNED.

Stage 5 - Abuse & Takedown

Sync Blocklist + Global Cache Purge

POST /shortensourceSync Safe-BrowsingrouterAsync Deep ScannerprocessorGlobal Edge PurgesinkQueue deep inspection

1.Fast Takedown: Global Pub/Sub purge evicts malicious L1/L2 cache entries across POPs within 2 seconds.

2.Rate-Limited Writes: Apply strict per-IP/API-key token buckets on POST /shorten to stop spam bots.

Combining sub-millisecond sync blocklists with async deep scanning stops abuse without slowing writes.

06
advanced

Clickstream Kafka + Flink Real-Time Analytics.

Why this matters: Deliver live click counts, geo maps, and bot-filtered unique visitors at 100K RPS.

Think of Clickstream Kafka + Flink Real-Time Analytics as the intuition layer for Design a Global URL Redirection Engine (100K RPS): Deliver live click counts, geo maps, and bot-filtered unique visitors at 100K RPS.

Each Edge POP batches click events asynchronously to regional Kafka clusters (short_clicks). Apache Flink jobs filter known bot User-Agents, enrich IP prefixes with MaxMind GeoIP (dropping raw IPs for GDPR), and compute 1-minute tumbling aggregations + HyperLogLog unique counts into ClickHouse.

Stage 6 - Clickstream

Edge-Batched Kafka + Flink Pipeline

Edge POP EmittersourceRegional KafkaprocessorFlink Bot & Geo JobcacheClickHouse OLAPsinkFilter bots & enrich

1.GDPR Compliance: Strip raw IP addresses inside Flink right after GeoIP lookup.

2.Zero Redirect Impact: Drop analytics buffers gracefully if Kafka backs up; never delay 302s.

Edge-batched Kafka ingestion and Flink enrichment scale analytics to 100K RPS cleanly.

07
advanced

TTL Expiration Engine & Tombstone Compaction.

Why this matters: Support expiring campaign links without degrading Cassandra read performance.

Links with expires_at store the timestamp in the payload and leverage Cassandra/DynamoDB TTLs.

Reading an expired cached entry checks now > expires_at lazily and returns 410 Gone.

Stage 7 - TTL Lifecycle

Point-Lookup TTL & Tombstone Cleanup

GET /short_codesourceLazy Expiry CheckrouterReturn 410 GonecacheNoSQL CompactionstorageServe 410 if expired

1.Point-Lookup Safety: Partitioning by short_code avoids multi-row tombstone scans.

2.410 Gone: Returning 410 lets Edge CDNs cache the expired state and stop origin hits.

Lazy expiration checks and partition-key point lookups keep TTL cleanup fast and safe.

Practice · Explain the consequences

Practice: Make the trade-off yourself.

Question 1 of 3
Score: 0/3

How does a Multi-Region URL Shortener generate globally unique short codes without paying 150ms+ cross-continent consensus latency on every write?

Recommended Learning Flow