Designing a URL Shortening Service like TinyURL
Lets design a URL Shortening service like TinyURL. This service will provide short short URLs for a large URL.
What is the Problem ?
URLs can be pretty huge depending upon the resources like the following :
https://news.google.com/topics/CAAqIggKIhxDQkFTRHdvSkwyMHZNREZqY0hsNUVnSmxiaWdBUAE?hl=en-IN&gl=IN&ceid=IN%3Aen ,
https://news.google.com/topics/CAAqIggKIhxDQkFTRHdvSkwyMHZNREZqY0hsNUVnSmxiaWdBUAE?hl=en-IN&gl=IN&ceid=IN%3Aen ,
I think this Shortening was majorly used in Twittor where there is a limit of 140 characters.
Requirements of the System
Its always necessary to clear out the requirements with the Stakeholders on what are the expectations they are making, This will ensure that our System is designed as per the Requirements.
Questions which are already answered
- We need to design a system which will store a shorter version of URL that was given.
- When somebody clicks that shorter URL , request will hit our Service and they will be redirected to the original URL.
Questions which needs to be answered before designing System
- Are Users allowed to pick among a list of URLs to choose ?
- For how long we will be storing the actual URL and shorter version of it ?
- Who will be our clients : Browsers or Applications or Both ?
- Do we need to apply authentication and authorization on this ?
- What kind of metrics are required like How many times a particular URL was redirected ? Do we need to store who all accessed it ?
- What is maximum allowed length of shortened URLs ?
Once we start asking questions about the problem and related parameters to it we are starting deeper into the Problem Scenario. Some of the above questions will be linked to Design and lets say we will be asked how much there is our capability to do this.
Following Questions will be asked for which we need to find answers from Technology Capability available today
- What is the shortest length or URL that our Service can support.
- What is the maximum time duration for which we can store these URLs.
- What it will take to have our Service be called from Browsers as well as Applications.
- What is the complexity of involving authentication and authorization in our Service.