Design a URL Shortening Service

Design a URL shortening service like TinyURL. This service will provide short aliases redirecting to long URLs.

Requirements:

  • Given a URL, our service should generate a shorter and unique alias of it
  • When users access a short link, our service should redirect them to the original link
  • Users should optionally be able to pick a custom short link for their URL
  • Links will expire after a standard default timespan

Constraints:

  • The system should be highly available
  • URL redirection should happen in real-time with minimal latency
  • Shortened links should not be guessable