在分布式数据存储中生成短URL [英] Generating short URLs in a distributed data store
问题描述
当前,我运行的Web应用程序严重依赖链接到原始内容的短URL,这些URL必须尽可能短.
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.
此刻,我使用一个简单的MySQL数据存储来存储这些对象,并使用递增计数器->以62为基础的转换来生成短网址,该网址会随着时间的推移而增长.我们需要转移到一个更加分布式和可扩展的环境.
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.
为分布式数据存储中的内容生成小的,唯一的简短Urls的最佳方法是什么?具体来说,我们计划使用 Mongo 或
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?
有关mongo的特定用例,请参见 http://dllhell.net/2010/07/23/on-sequences-with-mongodb-and-norm/
For the specific use case of mongo, see http://dllhell.net/2010/07/23/on-sequences-with-mongodb-and-norm/
这篇关于在分布式数据存储中生成短URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!