Requirements
Functional Requirements:
- there is 10 million user
- they can generate 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:
create User: post: /user :function createUser(username)
Url:
create URL: post: /generateUrl : function(userID,url)
get Url: get: / : function(URLParamse)
analytics:
update URL counter: put: function(urlID)
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.