Monday, August 3, 2015

Generating unique identifiers across a set of server nodes

Distributed systems come with their own set of problems. One of these problems is the generation of unique identifiers across multiple nodes. You can rely on the database to generate a sequential guid, but this hinders scalability and makes your systems error-prone.

While browsing through the MassTransit code base, I noticed they were using a separate NuGet package called NewId. NewId is a unique id generator with 2 important characteristics:

  • Unique Id generation at a specific server can happen without interaction with other servers
  • Id’s should be ordered(important for database optimization)

It’s inspired by (the retired) Twitter Snowflake and Boundary Flake implementations.

Certainly useful if you need to build scalable solutions…