Requirements
Functional Requirements:
- Create a short URL for a given long URL.
- Take the long URL, if already there and return the required shorter URL
Non-Functional Requirements:
- Latency - The URL should be created within 100ms and same goes for the redirection of the URL when the short URL is called.
- Consistency - The system should be highly consistent, we cannot tolerate wrong redirection
- Availablitlty - The system should be available all the time, for better user experience
- 1 billion daily users, 10% active users so 100 million each creartinf 5 requests a day - so 500M requests a day
- from this consider 20% are for creating up the URL and 80% accessing the correct full path based on the provided short URL
Capacity Estimation
There are total 100 Billion users out of which there are active 10% users daily, so the count comes to 100 million Daily active users out of this each user makes 5 requests a day
1- Create New URL
4- To redirect to the full path when calling the short url
API Design
APIs - (postmapping)/createURL/{full-path}
- (getmapping)/{Short-url} -> output (Long URL)
1- Client Applications (User Authorization, Load Balancing, API Gateways)
2- Service layer - this will hold the algorithm to create the short url's and store them in the hash map scenario in the application
3 - Model Layer from here the different API's will be called and redirected to the correct service layer
4- Horizontal scaling would be there to enable the equal distribution
Database Design
Define the data model. Identify the main entities, their attributes, and relationships. Consider the choice of database type (SQL vs NoSQL) and justify your decision based on access patterns...
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.