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.
Data can be partitioned using long url as the partitioning key.
Client
API gateway
Shortening service:
Redirection Service:
Analytics Service:
Authentication 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
Authenticate user: Authentication service verifies user and sends request to shorten service