Core (must-have):
tinyurl.com/abc123) and store the mapping.Nice-to-have (impressive additions): 3. Custom alias — Allow users to optionally specify a custom short path (e.g., tinyurl.com/mysite) instead of a random one. 4. Expiration (TTL) — Support optional expiry for short links (e.g., links valid for 24 hours or a custom duration). 5. Delete/update — Allow the creator to deactivate or update a link. 6. Basic analytics — Track click counts and referrers per short link.
performance, scalability , availability
Estimate the scale of the system. Consider daily active users, read/write ratio, storage requirements, bandwidth, and any relevant QPS calculations...
Define the APIs expected from the system. This is your chance to analyze and define the read and write paths so that you can come up with the high-level design...
We can have a microservice which gives api's to store a url and get an uuid. and store the actual url corresponding to that or update or deactivate the url.
user can use tinyurl/uuid to access the actual url
We will use a nosql db like aws which can be a global table and be replicated across regions.
we will use a redis cache in front of the the database.
We will write through cache for creation / update / deactivate of url. we will add events from cache for short term urls as per the ttl and the cache event for ttl will add an event to kafka and it will be consumed by the service and the short term url will be deactivated.
for analytics we will generate an event on each get call and track the no of hits and also store the geography etc asynchronously
analytics api's can be given to user separately
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 Use access patterns...
Deep dive into 2-3 key components. Explain how they work, how they scale, discuss tradeoffs, capacity, and any relevant algorithms or data structures.