highly available (99.99%)
highly scalable (billions)
low latency (100 ms)
data durable (links shouldn't break)
security against abuse
Throughput
new url - 1K/second
URL redirects - 1M reqeusts/second
Bandwith
Average URL size - 2KB
Read bandwithc - 1M (minimal size) ~ 100 MB
Write bandwidth - 1K * 2 KB - 2 MB
Storage
1K/sec * 86400 = 86M/day
URL per year = 86 * 365 = 31B
Storage per URL - 1KB
5 year storage - 32B * 1KB* 5 = 155TB
Define what APIs are expected from the system...
/getShortUrl(longUrl, alias, expiration) - shortUrl
/getLongUrl(shortUrl)
Analytics
/getUrlClicks(shortUrl, startDate, endData) - click count
URL mapping - no SQL database (fast key-value storage)
User Data - RDBMS
Analytics Data -t ime series dat a
Explain how the request flows from end to end in your high level design. Also you could draw a sequence diagram using the diagramming tool to enhance your explanation...
62 bits - 7 chars - 62^7 - 3.5 trillion possibilities (a-z, A-z, -09)
bloom filter to check if it already exists
TTL for URL (expire) periodic clean up
Database reads during hig traffic
URL collisions
analytics processing with custom aclias
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?