There should be an URL where user can provide the original url and on click on submit button tiny url will be generated and displayed in UI.
When user click on tiny url on browser then user should be redirected to original URL
system should be available 24x7
Response Time
100 million writes per day
10 billion read per day
sudden spiking in traffic is possible
An API to store the short URL into DB
An API to get the short URL as parameter and redirect user to original URL
Client will send request to server via UI.
When client will submit the request via UI, First request will come to load balancer. Load Balancer will pass the traffic to any API Gateway through round robin method which is connected to different API Node. Node 1 and Node 2. Each API Node will check if URL is stored in cache if yes then will provide that URL into DB else will fetch it from database. whenever URL request comes, we will store recent URLs into redis Cache or based upon requirment, we can check in last 30 minutes, how many X urls are accessed multiple times, only those URLs will be exposed. Client will authenticated to the system through OAuth.
We will use MS SQL DB as its having defined structure. Table
TinyURLList
ID
ShortURL
OriginalURL
IsDeleted
CreatedBy
CreatedTimeStamp
UpdatedBy
UpdatedTimeStamp
LogHistory
ID
UserID
ShortURL
RedirectURL
IsSuccess
IsDeleted
CreatedBy
CreatedTimeStamp
UpdatedBy
UpdatedTimeStamp
Load Balancer - Load Balancer to manage load between different API Gateway
API Gateway - Its used for Rate Limiting, WAF and prevention from DDos Attack.
API Nodes - Save URL API and Fetch Log URL API
Redis Cache - to store most frequently used API
SQL DB - To store the DB and User usage history.
API - use hashing and encoding to generate URL
Collision - Check Duplicate Check and Save URLs should be part of only on transaction to avoid any collision.