Actor: Visitor
Actor: Link creator
Actor: Power User
Actor: System
-----------------
Active Users: 200M
Traffic:
URLs created per user per day: 10 -> 2B writes/day -> 2B/86,400 -> 1/43 Million -> ~20K TPS
URL redirects per day: assume each short url is accessed on an avg 100 times. 100:1 read to write ration
URL redirects: 100 * 20 K ~= 2M TPS
At 10x peak = ~200k writes, 20M TPS reads
Storage:
Realistically, average long URL is ~200 chars and most users create <1 URL/day, bringing storage to ~10-100 GB/day." , per year 4TB-400TB.
POST /shorten
Request:
{ "long_url": "https://....." , "custom_alias": "my-link" (optional), "ttl_days": 30 (optional)}
Response (201):
{ "short_url": "http://tinyxyz.com/abc123", "expires_at": "2026-11-11T00:00:00Z" }
POST /report
Request:
{ "short_id": "abc123", "reason": "malware" }
Response:
{ "status": "reported" }
GET /{short_id}
HTTP/1.1 302 Found
Location: https://....
GET /{short_id}/stats
Response 200:
{ "clicks": 1533, "referrers": {...}, "geo": {..}}
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...
Deep dive into 2-3 key components. Explain how they work, how they scale, discuss tradeoffs, capacity, and any relevant algorithms or data structures.