01
Design a URL shortener that can support billions of links.
Tap to write answer
0 words | 0 charsPress Enter ↵ to reveal
Your Attempt
0 wordsRefined Model Answer
ReferenceI would start by clarifying whether we need custom aliases, expiration, analytics, and abuse protection, because each of those changes the design. My first version would store a mapping from short code to long URL in a durable database and use a fast read path for redirects. To scale to billions of links, I would shard the storage, cache hot redirects, and make the short-code generation collision-safe. The reason I would separate reads from writes is that redirect traffic is usually much heavier than link creation traffic. I would also think about rate limiting, deduplication, and how to recover if one shard goes down.