Snowflake ID explained

Summary:Infobox for punctuation marks
Bodystyle:max-width:18em;
Abovestyle:background:#ccc;font-size:200%;line-height:1.3;font-weight:normal;font-family:serif;
Header1:

Snowflake ID

Label2:Other names
Data2:Twitter Snowflake

Snowflake IDs, or snowflakes, are a form of unique identifier used in distributed computing. The format was created by Twitter (now X) and is used for the IDs of tweets. It is popularly believed that every snowflake has a unique structure, so they took the name "snowflake ID". The format has been adopted by other companies, including Discord and Instagram. The Mastodon social network uses a modified version.

Format

Snowflakes are 64 bits in binary. (Only 63 are used to fit in a signed integer.) The first 41 bits are a timestamp, representing milliseconds since the chosen epoch. The next 10 bits represent a machine ID, preventing clashes. Twelve more bits represent a per-machine sequence number, to allow creation of multiple snowflakes in the same millisecond. The final number is generally serialized in decimal.[1]

Snowflakes are sortable by time, because they are based on the time they were created. Additionally, the time a snowflake was created can be calculated from the snowflake. This can be used to get snowflakes (and their associated objects) that were created before or after a particular date.

Fixed header format
OffsetsOctet0123
OctetBit012345678910111213141516171819202122232425262728293031
000Timestamp - first 31 bits
432Timestamp - last 10 bitsMachine IDMachine Sequence Number

Example

A tweet produced by @Wikipedia in June 2022[2] has the snowflake ID . The number may be converted to binary as, with pipe symbols denoting the three parts of the ID.

Usage

The format was first announced by X/Twitter in June 2010.[4] Due to implementation challenges, they waited until later in the year to roll out the update.[5]

See also

External links

Notes and References

  1. Web site: twitter-archive/snowflake at b3f6a3c6ca . . January 18, 2021 . October 1, 2012.
  2. 1541815603606036480. Wikipedia. 53 years ago today, members of the LGBTQI+ community began protesting in New York City in response to a police raid of the Stonewall Inn, a popular gay bar. The riots were a transformative event in the 20th century fight for LGBTQI+ rights in the US. (1/2).
  3. Web site: 2019-08-03: TweetedAt: Finding Tweet Timestamps for Pre and Post Snowflake Tweet IDs . 2019-08-03.
  4. Web site: King . Ryan . Announcing Snowflake . blog.twitter.com . Twitter . January 18, 2021 . June 1, 2010.
  5. Web site: Siegler . MG . Tweet IDs About To Get Jumbled In A Blizzard As Snowflake Is Set To Roll Live . TechCrunch . January 18, 2021 . October 12, 2010.
  6. Web site: Twitter IDs . Twitter Developer . Twitter . January 20, 2021.
  7. Web site: API Reference . Discord Developer Portal . Discord . January 18, 2021.
  8. Web site: Sharding & IDs at Instagram . Instagram Engineering . January 18, 2021 . en . May 2, 2016.
  9. Source Code