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.)...
- scalability
- reliability
- low latency
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...
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.
So we will have a frontend hosted on a cdn which will make it fast and from there it will talk to backend through the load balancer to the server which can scale depending on the load. We will have a cache which will store the urls for a short amount of time lets say around 5 min after which they will be popped out. As far as database concerns I dont think it is required in this context.
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.
As mentioned in the high level design we will be using cdn for frontend making it very efficient. We will be using auto scaling for the backend so that it can scale depending on the load. Since this is horizontal scaling we would need a load balancer which would balance the load. Im thinking of distributing the load based on the amount of load a server has on it. This strategy avoids overloading one server with getting the hits. For cache we will use redis to store the shortened url and the original url as key value pairs. Coming to the shorting logic we can maybe use a format such as first 5 letters from the original url domain and add a 4 digit random base64 code making it somewhat readable and random since base64 can be generated randomly.