Design a URL Shortener
Requirements: Design a URL-shortening service: given a long URL, generate a short unique alias; given the short alias, redirect to the original URL; support high read (redirect) traffic.
Design: Generate short codes either via a base62-encoded auto-incrementing ID (simple, guarantees uniqueness, but reveals scale/creates hot-spotting on the ID generator) or via hashing the URL (MD5/SHA) truncated to N chars with collision-check-and-retry. Store the mapping in a key-value store optimized for fast point lookups (short_code -> long_url), fronted by a cache (e.g., Redis/CDN) since redirects are extremely read-heavy and long URLs rarely change. Discuss capacity estimation (QPS, storage growth), custom-alias support, expiring links, and analytics (click counts) as a separate async pipeline so it doesn't slow the redirect hot path.