Generating short URLs in a distributed data store

三世轮回 提交于 2019-12-08 07:27:03

问题


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.


回答1:


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/



来源:https://stackoverflow.com/questions/9951163/generating-short-urls-in-a-distributed-data-store

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!