URL shortening services (TinyURL, Bitly, Twitter t.co) appear deceptively simple on the surface: map a long URL to a compact 7-character string and issue an HTTP redirect when requested. However, operating this system at global scale—handling 100,000 read requests per second, billions of stored links, sub-10ms redirect latency, and continuous real-time clickstream analytics—demands rigorous distributed systems engineering.
A naive implementation relying on auto-incrementing database primary keys collapses immediately under horizontal database sharding, while random hashing runs headfirst into the birthday paradox collision wall.
This module deconstructs the end-to-end architecture of a distributed URL shortener and redirect engine: token generation mechanisms (MD5 truncation vs. Base62 counter ranges), ZooKeeper range coordinator leases, HTTP redirect status codes (301 vs 302) and their browser caching implications, multi-tier caching topologies, and edge Bloom filters protecting backing storage.