List functional requirements for the system (Ask the chat bot for hints if stuck.)...
List non-functional requirements for the system...
We'll estimate that there will be 1 million URLs generated per day.
Writes: 1 million / day
Writes per second: 1 million / 24 / 3600 = 11.57
Reads: We'll make an assumption that this is a read heavy system of 10:1 so there will be 10 million reads per day with a read per second of 11.57 * 10 = 115.7
Number of records over 10 years: 1 million * 365 * 10 = 3.65 million records
Assume average URL length will be 100 characters
Storage requirements over 10 years is 3.65 million * 100 bytes = 365 million bytes
POST api/v1/data/shorten
GET api/v1/data/shortUrl
See ER Diagram
See HLD.
See Sequence Diagram.
Hashing the long url into a short url:
If we fail to retrieve the long URL during this process then we can't perform a 301 redirect. In this scenario, we would place the user on the tinyurl web page and notify them that the redirect did not work.
We need a distributed unique id generator to ensure the base 62 conversion operates on a globally unique ID.
Some areas of improvement are how to handle malicious requests to shorten a URL. We can use rate limiting to rate limit based on user IP address as one potential solution.
The database itself could be sharded or replicated since right now it acts as a single point of failure.