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.

有帮助吗?

解决方案

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/

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top