Shorten url system design


Design a url shortening service. like

Use case

  1. Shortening: given a url -> return a much shorten url.
  2. Redirection: take a shorten url -> redirect to the original url.
  3. Custom url.
  4. High availability of the system.

Tasks break down

  1. New urls per month: 100M.
  2. 1 billion request per month.
  3. 10% from shortening and 90% from redirection
  4. Request per second: 400 (40: shortens; 360:redirection).
  5. 6 billions in 5 years.
  6. 500 bytes per url.
  7. 6 bytes per hash.
  8. 3TB for all urls, 36GB for all hashes (over 5 years).
  9. New data was written per second: 40*(500+6):20K.
  10. Data read per second: 360*506 bytes: 180K.

Abstract Design

  1. Application service layer (serves the requests)
  • shortening service.
  • redirection service.
  1. Data storage layer (keeps track the hash -> url mappings)
  • Acts like a big hash table: stores new mappings and retrieves a value given a key.

hashed_url = convert_to_base62(md5(orginal_url + random_salt))[:6]


Traffic is probably not going to be very hard, data - more interesting.