@shashipk11 Very nice write up.
One thing to note is that when you set up a db for auto increment and if you make it distributed - then if you have to add a node or remove a node and rebalance the data, there will ID collision since each node has auto increment.
db1-123, 456, 789
db2-123, 456, 789
Even though content is differnet (original and short url), all ids in nodes will be same.
You're doing correct routing but ID has to be unique. If you want to rebalance data, add or delete node, you get id collisions.
To fix this - you can use two (or more) db just to create ids - ID_db1 creates odd id, ID_db2 creates even number ids. (basically just
return id if (id % (1 for ID_db1 or 2 for ID_db2) == 0) else auto_increment). So even if one db goes down, we still proceed and fix and resume the process.
And now this id can be used in whatever nodes you wish by directly apply consistent hash on this id. no collision problem.