Requirements


Functional Requirements:


  • there is 10 million user
  • they can generate url this will also generate shorten url
  • there needs to be api which will return shortened url for given url
  • this url expiry after 60 days
  • 100000 QPS read
  • if we get url size of 4kb and 2kb for strage purpose and have exipiry of 60 days so storage will be reqired of total 6kb for each row lets take 10 kb to add timestamp and user id as well so total storage would be 10*10000000*60 total 600gb of data base is require
  • need to have analytics for how many url is generated by user and how many click is there




Non-Functional Requirements:


  • system needs to be up and running and p99 should be less than 1 sec.
  • as its read heavy database we can use Mysql with slave and master architecture
  • need to scale automatically with sudden burst of request Horizontal scale
  • rate limiting


API Design


User:

post: /user #create User


Url:

post: /url : function(userID, url) #to generate URL

get : /lookup/{url} : function(url) # to get associated redirect url

get : /reverse-lookup/{url} #give shortened url of given actual URL

get:/{tinyURL} # redirect to actual URL



High-Level Design

Describe the overall system architecture. Identify the main components needed to solve the problem end-to-end. Use the diagramming tool to create a block diagram.




Detailed Component Design

Deep dive into 2-3 key components. Explain how they work, how they scale, discuss tradeoffs, capacity, and any relevant algorithms or data structures.