Thursday, July 14, 2011

SnowMaker Released - A human readable unique Id generator that cloud scales (i.e. for Azure)

Tatham Oddie - Released: SnowMaker – a unique id generator for Azure (or any other cloud hosting environment)

"What it solves

Imagine you’re building an e-commerce site on Azure.

You need to generate order numbers, and they absolutely must be unique.

A few options come to mind initially:

  • Let SQL Azure generate the numbers for you. The downside to this approach is that you’re now serializing all of your writes down to a single thread, and throwing away all of the possible benefits from something like a queuing architecture. (Sidenote: on my current project we’re using a NoSQL graph DB with eventual consistency between nodes, so this wouldn’t work for us anyway.)
  • Use a GUID. These are far from human friendly. Seriously, can you imagine seeing an order form with a GUID on the top?
  • Prefix numbers with some form of machine specific identifier. This now requires some way to uniquely identify each node, which isn’t very cloud-like.

As you can see, this gets complex quickly.

SnowMaker is here to help.

What it does

SnowMaker generates unique ids for you in a highly distributed and highly performant way.

  • Ids are guaranteed to be unique, even if your web/worker role crashes.
  • Ids are longs (and thus human readable).
  • It requires absolutely no node-specific configuration.
  • Most id generation doesn’t even require any off-box communication.

How to get it ..."

I think GUIDS are nice for hidden keys, but never for human consumed ID's. They are just not viable for that use case (leaving aside the clustered index conversations). This looks like an interesting solution and made me think of the new Sequence object coming in SQL Server Denali. Still this is available today AND you get the source. :)

No comments: