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:


  • List the key non-functional requirements (eg low latency, scalability, reliability, etc.)...
  • high availability
  • low latency
  • horizontal scaling


API Design

Define the APIs expected from the system. This is your chance to analyze and define the read and write paths so that you can come up with the high-level design...


  • API to get shortened URL
  • API to get long URL from shortened URL
  • API to get the web page from shortened URL


High-Level Design

Describe the overall system architecture. Identify the main components needed to solve the problem end-to-end. Use the diagramming tool to create a block diagram.

  • client who will be using the system
  • Load balancers who will receive the requests and redirect to appropriate API servers
  • API servers which will handle the API requests mentioned above
  • In memory cache for fast reading of existing and frequently used tiny URLs. We can use Redis for this.
  • SQL database for storing mapping from long URL to short URL and vice versa. Can set up a MySQL database.


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.

  • For each URL being input to get the shortened URL, we need to check if it already exists in the system. Most frequently used will be kept in Redis with some set key expiration time.
  • If the URL is not present in cache or DB, we will add it to the the DB, get the ID and get the base62 of the ID to generate the shortened URL.
  • API servers will also handle any requests to access shortened URLs by redirecting them to the actual long URL.