We will be using a NoSQL key-value database to store our data. It is quick to access and write to since we don't have any relational entities.
Key / value
shortened_url(key): {
redirect_url: the redirect url
created_at: The timestamp at which the shortened_url was created
}
Building blocks:
Generating shortened URL
Accessing a shortened URL:
The rate limitter will protect us from DoS attacks by mitigating quick bursts of traffic. It will also protect our limited short codes from getting depleted too quick by disallowing clients from making too many shortened urls too quickly
The L3 load balancer will sit at the network layer where it will efficiently route traffic with little overhead.
The Database will be a sharded redis database. Redis has built-in support for sharding as well as replication so that abstraction will result in less difficulties when integrating.
The range handler will allocated a range of shortened url codes to each sharded db instance. This is so we don't have any overlap or fighting for shortened url codes. There will also be a lower chance of conflicting codes.
I chose to use redis compared to memcached since redis has more built-in abstractions for sharding/replication.
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?