The SYSTEM should return the TinyURL when a long URL is provided and mapped to a TinyURL.
The SYSTEM should create and return a TinyURL when a long URL is provided, and the long URL is not mapped to a Tiny URL
The SYSTEM should maintain the Tiny URL mapped to the long URL for 5 years.
The SYSTEM should return the long URL mapped tot he TinyURL when the TinyURL exists.
A TinyURL will be defined by 14 bytes, 1 byte of server ID, 4 bytes to represent the date, 3 bytes to represent the time and the last 6 bytes to represent the fractional seconds.
GET: Get_TinyURL
{
"TinyURL" : <Tiny URL>,
"Long URL" : <long URL>
}
DELETE: Delete_URL
{
"TinyURL" : <Tiny URL>,
"Long URL" : <long URL>
}
Columnar Database: Cassandra. Cassandra guarantees the database will be scalable, available, and partition tolerant.
TinyURL : Primary Key
LongURL : Secondary URL
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...
Application Servers: The algorithm to generate the Tiny URL will use a timestamp adding as a prefix the id of the server generating the Tiny URL. Considering the Write Operation will be about 1 / sec, a timestamp with the server ID as a prefix will be enough to avoid collisions and generate unique URLs.
Two TinyURLs mapped to a Long URL. Cassandra prioritizes Availability and Partition Tolerance over Consistency. However, due the use case of the Tiny URL, there customer experience will not be affected if either of the two generated Tiny URLs are used.
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?