Distributed Snowflake ID Generator

Based on Twitter Snowflake

Currently being used to generate IDs for Sleeperbot in Cassandra/ScyllaDB.

Architecture

Snowflake allows the user to specify the nodes in the cluster, each representing a machine. Snowflake at startup inspects itself for IP and Host information and derives its machine_id from the location of itself in the list of nodes defined in the config.

You can use Private IP, Public IP, Hostname, or FQDN as a way to specify the nodes, making deployment in production easy. A cluster of snowflakes is distributed, uncoordinated, and guaranteed to be unique. Attach snowflake as a dependency to whatever service you are running that requires it.

6 Likes