Ability to take the url and return short version that could be map to the original one
We would have two api:
The most perfect database here is persist kv store.
Since kv stores are usually NoSql, so we choose NoSql to be our database and we don't need to worry about scaling too much.
I'd like the database to be replicating synchronously within the datacenter and async outside the datacenter. That could gurantee the strong consistence.
Version conflicts are not big issue for us as we won't have tons of duplicate records and two short-url can be mapped to a same url
There are 2 tradeoffs I made there:
We do have few things which are SPOF - we can deploy many LB, servers and database nodes and cache nodes, but we should be very careful with the algorithm that generate short URL.
What are some future improvements you would make? How would you mitigate the failure scenario(s) you described above?
Since our system is eventually consistency, in most cases it would be fine. But in special case there would be problems.
For example, if a famous person post a short link, and it's been requested by massive traffic before replicates to all nodes, it would cause two problem:
How to fix it?
For the specific user or famous user, we use push based approach in cache, that means we write cache during write request flow, that could leads the read requests to cache and lower the stress of DB