Skip to content
RED SAGSkills
hardBackend Developer interview question

Design a URL shortener like bit.ly that handles 100 million new links per month and many more redirects. Cover IDs, storage, caching and scale.

What the interviewer wants to hear

  • Estimate scale: read-heavy, storage size, QPS
  • Short ID generation: counter with base62, or random with collision check
  • Key-value style storage, indexed by short code
  • Heavy caching and CDN for redirects; 301 vs 302 trade-off
  • Analytics asynchronously via a queue; abuse protection

Model answer

At 100 million links a month, writes are around 40 per second on average, but redirects may be 100 times more, so the system is read-heavy. Over five years that is about 6 billion links; with around 500 bytes each, a few terabytes. For IDs, 7 base62 characters give about 3.5 trillion combinations. I would use a distributed ID generator, for example ranges of counter values handed to each server, then base62 encode, which avoids collisions. Random IDs also work with a unique constraint and retry. Storage is a simple key-value lookup by short code, so DynamoDB, Cassandra or sharded PostgreSQL fit. Redirects go through Redis and a CDN since popular links are hot. I would use 302 if we need click analytics, because 301 is cached by browsers. Click events go to Kafka and are aggregated asynchronously. I would add rate limiting and malware URL checks.

Can you answer it under time pressure?

Take a timed hard round and get scored on every answer.

Start mock interview

More hard Backend Developer questions