API to Generate url Shortner if you give long url
API to Redirect it to long url when short url is given
short url length will be 7
can contain 0-9a-zA-Z
Click analysis
URL size = 100 byte = 100 * 10^6 * 365 * 5
180 GB for 5 years
1 /generateShortURL
long url as body
2 /redirectULR/shortURL
Components:
tinyURL Service
Counter cache
load balancer
rate limiter service
Auth service
DB service
CDN
Define the data model. Identify the main entities, their attributes, and relationships. Consider the choice of database type (SQL vs NoSQL) and justify your decision based on access patterns...
CDN -> It will store some popular urls, Client will call CDN if url is present , it will be temporary redirected to that original URL
Also increase the count of url click and then synchronize data with analysis service.
Load Balancer -> with the help of consistent hashing , we will distribute the call to tinyurl service
TinyURL service:
generate 7 length url
redirect to long url
Rate limiter service :
this service will take care of no if api calls to tiny url per user
Counter Cache:
each tiny url service will take 10k range from counter service and generate 7 length unique url using base 62
DB :
As there is not much join in data
it is like a key value
we can store in nosql db
as user increase ,we can shard the db with tiny url
Failure Scenario:
If any tiny url service fail , there is multiple service it will take care of it