Questions:
We have read bias
Store Links indefinitely require an DB cluster
Average link data is size 200 characters
1M links per day
200M character each day in the DB this gives us 6 Billion characters in the DB or 6GB a month.
5 years projection: 360 GB
Inbound traffic for link creation is 6GB a day
Inbound traffic for link redirection 1GB a day given 100 million short url redirections.
Post /v1/shorten
Body {"url": "
return 201 // no content
return 400 no valid url exists in the body
return 500 internal server error {"errorCode: int, message: ""}
GET
return 302 redirect
return 404 no short url found
return 500 internal server error {"errorCode: int, message: ""}
Notes on technology selection:
Scalability:
Low Latency:
Availability:
Database can have a basic table called URLs, it has very basic information based on the requirements above. since we are user agnostic then the URL should be maybe have URL, hash, created at and last accessed (this will help with crashes later to auto reload last access URL/hot URLs) the last access at field will be pushed as a bulk snapshot from the KV store.
Database can be shared using hash ranges to have stable shards and avoid re-balancing.
Since this is a read heavy system we can have read replicas for the URLs, with read repair (maybe),read from active replica or read your own writes to provide strong consistency.
Client:
API:
URLProcessor: