Question

Currently I run a web app that heavily relies on short URLs that link to the original content, these URLs need to be as short as possible.

At the moment, I use a simple MySQL data store for storing these objects and an incrementing counter -> base 62 conversion to generate short urls that will grow over time. We need to move to a more distributed and scalable environment.

What is the best way of generating small, unique short Urls for content in a distributed data store? To be specific we plan to use either Mongo or DynamoDB.

Was it helpful?

Solution

I'd suggest you have a look at Jon Skeet's description of the HiLo algorithm here: What's the Hi/Lo algorithm?

For the specific use case of mongo, see http://dllhell.net/2010/07/23/on-sequences-with-mongodb-and-norm/

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top