开发者

Generating unique primary Ids of int32 & int64 sizes

I am developing a social web application using Java and a distributed noSQL DB(Cassandra). I need to generate ids for new users and posts on the application in the sizes of 32bits and 64 bits respectively.

Because of building on top of a distributed platform, our problem of generating ids/keys has become somewhat more complicated. Although there have come solutions like Zookeeper/ or twitter's snowflake which have helpfully been trying to alleviate this pain, but these solutions do not seem to simple to just use.

After looking at these solutions from a top level view, I feel going with the most simple solution and most mature. Using MySQL database like the way flickr's ticket servers, comes to my mind as the first preference as it seems to be the most easiest solution.

http://code.flickr.com/blog/2010/02/08/ticket-servers-distributed-unique-primary-keys-on-the-cheap/

I know that will create SPOF around a distributed system.. but still I believe this would be the most easiest solution for my early days(when I have less resources in terms of capital and manpower). When my application grows I believe switching would be no difficult as they is no heavy data to be transferred. So for the infancy state of my application I guess MySQL can serve me in the best and simplest manner to generate Ids.

Major factors for this choice:-

  1.   Easier Implementation
  2.   Easy switching anytime in the future
  3.   Mature
  4.   MySQL may be required for our other needs as well, already 

I am thinking of using a single MySQL server initially and later switch to li开发者_开发问答ke two servers as flickr's solution inorder to remove SPOF.

Can somebody point out what issues may arise later when I consider switching to an alternate solution like zookeeper or snowflake? Or what may be the downsides of proposed current approach?

Thanks a lot for your time!


I know that will create SPOF around a distributed system.. but still I believe this would be the most easiest solution for my early days

No, the easiest solution is to use the identifiers that your distributed dbms provides. That way avoids

  • separate server hardware for MySQL
  • installing, configuring, and securing another operating system
  • installing, configuring, and securing another dbms

And you probably need sequentiality a lot less than you want it.

I know that will create SPOF around a distributed system.

It will create multiple single points of failure. Odds are good that each piece of server hardware, except possibly the disks, are single points of failure. (How many power supplies are you going to put in there? How many disk controllers? How many NICs?) There are a legion of software single points of failure, too.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜