Assuming 100 million total users,
and 50M daily users.
Each generates 10 short URLs.
one row in DB size: 180 bytes => 0.18 kb
short URL - 32 bytes
long URL - 100 bytes
date - 40 bytes
user Id - 8 bytes
daily 50M users => 50 * 10^5 * 10 * 180 => 9 * 10^8 bytes
annually => 9 * 10^8 * 365 bytes minimum DB size.
bandwidth required - each user takes 10 kb/s
daily 50M - 10 * 10^3 * 50 * 10^5 b/s
at peak load = 10^9 kb/s of bandwidth is required.
POST: /createShortUrl, data: {"longUrl": "http://thelongurl.com"}
GET: /{uniqueShortId}
DELETE: /removeOldUrl
PATCH: /updateShortUrl/{uniqueShortId}, data: {"longUrl": "http://thelongurl2.com"}
GET: /health
GET: /stats/{uniqueShortId}
URL_TABLE
URL_STATS
USER_TABLE
User logins using username and password -> requests a short URL giving an original long URL -> system checks if data exists, if not creates short url saves it in cache and DB -> system returns short URL to user -> user hits short URL -> system checks if corresponding short URL exists if yes checks the cache for original URL if not found fetches it from DB, stores it in cache -> redirects user to original URL.
Dig deeper into 2-3 components and explain in detail how they work. For example, how well does each component scale? Any relevant algorithm or data structure you like to use for a component? Also you could draw a diagram using the diagramming tool to enhance your design...
Explain any trade offs you have made and why you made certain tech choices...
Try to discuss as many failure scenarios/bottlenecks as possible.
What are some future improvements you would make? How would you mitigate the failure scenario(s) you described above?