Snowflake ID

The Snowflake ID is a unique identifier created by Twitter for distributed computing.

The IDs are made up of the following components:

  • Epoch timestamp in millisecond precision - 41 bits
  • Machine id - 10 bits
  • Sequence number - 12 bits

SnowFlake (1).png

The following are some of the benefits of creating Unique IDs in snowflake format:

  • It consists entirely of integers.Indexing of integers are much faster than indexing strings

  • Keys begin with a timestamp, so are sortable.

  • This is efficient and fits in the size of a bigint.

Ref:

https://github.com/twitter-archive/snowflake/tree/snowflake-2010

https://blog.twitter.com/engineering/en_us/a/2010/announcing-snowflake