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
  • high availability


API Design

POST: /create-url

GET: /{short-url}



High-Level Design

The client makes a request which will be routed through the CDN and the API gateway to the load balancer. The load balancer decides which shortner service instance the request is routed to. The shortner service will shorten the long url to a short url. If the url is already shortened and accessed frequentky, it can be accessed from the cache, else it will be stored in the database and will be fetched from there.



Detailed Component Design

Deep dive into 2-3 key components. Explain how they work, how they scale, discuss tradeoffs, capacity, and any relevant algorithms or data structures.