Estimate the scale of the system. Consider daily active users, read/write ratio, storage requirements, bandwidth, and any relevant QPS calculations...
Shorter should have 2 endpoints for
shortenUrl(url) - returns shortened url to the user, and stores in DB - POST.
getUrl(shortUrl) GET - fetches url and redirects to the user.
we have cdn for finding closes server,
load balancer for redirecting user to closes API
2 microservices shortner service and redirect service.
Shortner stores most recent ursl into redis and dynamo db.
for sake of latency we fetch newly created urls from redis cache.
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...
shortener service when gets url generates short hash for it and stores to nosql db with key being short hash and value being actual url.
redirect service when recieves short url fetches it via db query with short url as a key and throws redirect request with the long url value.