Requirements


Functional Requirements:


  • Create a short URL for a given long URL.
  • Return the long URL associated with a given short URL.



Non-Functional Requirements:


  • Low latency
  • Reliability
  • Availability
  • Scalability
  • Fault Tolerance


API Design

  • createShortURL(url: String): void
  • getURL: String
  • getMetrics: Object


High-Level Design

  • Region 1 and Region 2 are identical - database replication is needed.
  • Geo Load Balancer: to geo route requests across regions
  • Horizontally Scalable Web Servers: To serve UI to allow users to create short URLs. Also to allow users to collect metrics about the URLs they created. Also to retrieve URLs and redirect users to destination URL.
  • Horizontally Scalable API Servers: To call createShortURL, getURL, and getMetrics APIs
  • Sharded Database: Horizontally scaled database to allow hashing and storing huge numbers of URLs. Also to allow fast retrieval of URLs.
  • Horizontally Scalable Caching Servers: To cache frequently recently used URLs (evicting LRU URLs) to avoid storing irrelevant URLs that may not be trendy in the near past.



Detailed Component Design