URL Shortening:
1.The system should provide a mechanism to shorten long URLs.
2.Shorten URLS should be unique and not collide with existing ones
Redirection:
3.When users access a shortened URL, they should be redirected to the original long URL.
4.The redirection process should be fast and seamless.
--- Extra if asked
Custom Alias:
5.Users should have the option to customize their short URLs with a chosen alias (if available).
6.Alias should be unique across the system.
Expiration:
7.Provide an option for users to set an expiration date for their short URLs.
8.The link will by default expire after a certain period if no expiration date is set.
Scalability:
1.The system should handle a large number of URL shortening requests and clicks.
2.Scalability should be achieved through horizontal scaling.
Performance:
3.The redirection process should be fast, with minimal latency.
4.Ensure that the system can handle concurrent access without performance degradation.
Reliability:
5.The service should be highly available and have minimal downtime.
6.Implement mechanisms for fault tolerance and disaster recovery.
Storage:
7.Efficiently store and retrieve a large number of short URLs and their associated data.
8.Use reliable and scalable storage solutions.
Backup and Recovery:
1.Regularly backup data to prevent data loss.
2.Implement a recovery process to restore data in case of failures.
Let us assume our service will have the following usage patterns:
Below are the number of url that we will have to store in our database for a 5 year period: 30 million * 5 years * 12 months = 1.8 Billion
Storage Estimation for 5 years:
Total: ~1TB for 5 years (per database)
Defining the system data model early on will clarify how data will flow among different components of the system. Also you could draw an ER diagram using the diagramming tool to enhance your design...
You should identify enough components that are needed to solve the actual problem from end to end. Also remember to draw a block diagram using the diagramming tool to augment your design. If you are unfamiliar with the tool, you can simply describe your design to the chat bot and ask it to generate a starter diagram for you to modify...
user --> LoadBalancer --> Application Server ( URL shorening service) APIS
Application Server --> checks in database if present return short uRL,
We can use in-memory caches like Redis or Memcached to store the most frequently accessed URLs.
if not found, generate short end url and save it.
Hashing or ID Generation: A unique short URL is generated using techniques such as:
a-z, A-Z, 0-9)URL redirection service:
Same given shortURL, if found in storeage return.
or else error
Caching: Redis
Database:
MSSQL: DataIntegrtity, Scalling through Sharding
MongoDB : large Dataset, with flexible design, slowers the read. Not
Cassandra/Dynamo DB:
For highly scalable, distributed systems, you can use NoSQL databases like Cassandra or DynamoDB. These are great for horizontally scaling out the system and providing high availability
Using a NoSQL database for a URL shortening service has several advantages, making it a good choice for certain aspects of the system. Here are some reasons why a NoSQL database may be suitable for this scenario:
Explain how the request flows from end to end in your high level design. Also you could draw a sequence diagram using the diagramming tool to enhance your explanation...
Dig deeper into 2-3 components and explain in detail how they work. For example, how well does each component scale? Any relevant algorithm or data structure you like to use for a component? Also you could draw a diagram using the diagramming tool to enhance your design...
Explain any trade offs you have made and why you made certain tech choices...
Try to discuss as many failure scenarios/bottlenecks as possible.
What are some future improvements you would make? How would you mitigate the failure scenario(s) you described above?