Friday, April 10, 2020

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 , 

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 

  1. We need to design a system which will store a shorter version of URL that was given.
  2. 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 

  1. Are Users allowed to pick among a list of URLs to choose ?
  2. For how long we will be storing the actual URL and shorter version of it ?
  3. Who will be our clients  : Browsers or Applications or Both ?
  4. Do we need to apply authentication and authorization on this ?
  5. What kind of metrics are required like How many times a  particular URL was redirected ? Do we need to store who all accessed it ?
  6. 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 

  1. What is the shortest length or URL that our Service can support.
  2. What is the maximum time duration for which we can store these URLs.
  3. What it will take to have our Service be called from Browsers as well as Applications. 
  4. What is the complexity of involving authentication and authorization in our Service.