URLs to shorten - 200/sec
Redirection traffic - 20000 redirects/sec
Avg size of long URL - 2KB
Avg size of short URL - 256B or 0.256KB
User metadata: 5KB
Total data to be stored - 200 * 60 * 60 * 24 * 10KB = 172 GB per day
shortenURL()
input: long URL, user id
output: short URL
redirect()
input: short URL, user id
output: redirection to long URL
Use key value store like dynamodb for strong consistency and scalability for large amount of data
Client
API gateway
Shortening service:
Redirection Service:
DynamoDB:
Cache:
Shorten URL: Client sends long URL for shortening. Service shortens URL. Store long-short URL in DB and update cache
Redirect: Client sends request with short URL. Access short URL from cache. If not present in cache, get it from database
Explain any trade offs you have made and why you made certain tech choices...
What are some future improvements you would make? How would you mitigate the failure scenario(s) you described above?