Functional Requirement :
1) User generate short url for big url
2) User is able to redirect to the orginal link from the short url
3) User can create profile and create url associated with its profile
1) Scalable -> add more url, and server more redirect
2) Latency -> 5ms ?
3) Available -> as much as possible
4) Read Heavy
API Design
Get /shortCode -> redirect to big url
Post { bigurl } -> return { shortUrl , expiry }
High-Level Design
client -> gateway -> user Service -> userDb
UserDb { id , userName , name , emailId , phoneNumber }
Postgresql vs ?
WHAT SHOULD BE THE OTHER DATABASE I SHOULD CONSIDER FOR TRADEOFF AND THEN MAKE A COMPARISON
client -> gateway -> url Service -> urlDb
urlDb{ id , shortUrl , longUrl , expiry }
Redis vs Postgresql
REDIS BECAUSE THERE IS EXPIRY FEATURE AS WELL AS SHORT URL KEY VS POSTGREQ SQL FOR QUERY , read is faster in redis, with faster query than index and also more concurrent reads and also ttl
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.