Client: Web browsers, mobile apps, or API clients send requests.
DNS & Global CDN / Anycast: Routes requests to nearest region. Static assets & top redirect caches.
Load Balancers (Nginx / ALB): Terminates SSL and distributes traffic across application microservices.
URL Shortening Service (Write Service): Handles generation of short codes and persists mapping into the database. Uses a pre-generated Key Generation Service (KGS) or distributed Snowflake ID generator converted to Base62.
URL Redirection Service (Read Service): Stateless read replicas optimized for high-throughput queries. Looks up short code in distributed cache first, then falls back to read database replica.
Distributed In-Memory Cache (Redis Cluster / Memcached): Caches hot short-to-long URL mappings (LRU eviction). Handles 80-90%+ of read requests directly.
Primary Database (Distributed NoSQL e.g., Cassandra / DynamoDB or Sharded PostgreSQL): Key-value store mapping short_code -> URL record. Highly scalable and partition-tolerant.
Asynchronous Event Stream (Kafka / RabbitMQ): Click events emitted on each redirect without slowing down HTTP redirect response.
Analytics Worker & Time-Series DB (ClickHouse / ElasticSearch): Consumes click events to aggregate metrics and dashboards.