Create a short URL
Redirect to Long URL
High Availability
Low latency
Scalability
Data Consistency
DAU: 5x10^5
RPS: 5
$basename/v1/short-url/
$basename/v1/bulk-short-urls/
short-URL
The idea is to have two services:
The hashing service will be doing a transformation of ascii characters, the transformation can be just chaning the base ascii letters.
Creation flow
Query flow
Cache will be done with redis, and the idea is to have enough replicas to serve the demands.
The database will be a noSQL or non relational database, since there are not complex relationships.
REST API design will consider a CRUD for short-url, and a bulk-url for cases where multiple urls might be required (like the one used on chatgpt, or linkedin).
Having a non-sql database might compromise consistency, however a usual use case doesn't require a lot of updates for shorturls.
A point of failure might be having hashing collisions, in such case we would need to increase the basis used to transform the long URLs properly.
I would add another service to rebalance the hashing bassis, in this way we have less collisions.