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:
- High Availabilty - Upto 99% uptime.
- Low Latency - Request taking upto 5ms.
- Scalable - The system should support horizontal scalability by allowing the addition of more servers and utilizing a load balancer to manage incoming traffic. This ensures that if one server fails, others can continue to handle requests, maintaining high availability.
API Design
/create - POST - Route to get the longURL from the user, and give back a shortURL.
/redirect/:shortURL - GET - Route to redirect the user the original URL.
High-Level Design
- A Web Server for handling the API requests.
- A Database storing the URL mappings (short URL to Long URL).
- Load Balancer to distribute traffic across multiple servers.
- A Cache Layer to improve the reads.
Detailed Component Design
- Web Server - To handle the web Requests.
- Multiple Backend Servers - To handle the requests form the users, like shortning the URL, getting the mapping for the short URLs.
- Database - For storing the Mapping of short and Long URLs along with an expiration date so that the database does not gets overloaded.
- Load Balancer - For redirecting the traffic according to the server availability.
- A Cache Layer - For faster retrieval of mappings