Snowflake ID: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
m phrasing
No edit summary
Line 20: Line 20:
==References==
==References==
{{reflist}}
{{reflist}}

==External links==
*{{GitHub|https://github.com/twitter-archive/snowflake/commit/b3f6a3c6ca8e1b6847baa6ff42bf72201e2c2231|Twitter's reference implementation}}


[[Category:Twitter]]
[[Category:Twitter]]

Revision as of 17:27, 18 January 2021

Snowflake IDs are a form of unique identifier used in distributed computing. The format was created by Twitter and is used for the IDs of tweets.

Format

Snowflake IDs are 64 bits. The first 41 bits are a timestamp, representing milliseconds since the chosen epoch. The next 10 bits represent a machine ID, preventing clashes. The remaining 12 bits represent a sequence number, to allow creation of multiple snowflake IDs in the same millisecond.[1]

Since snowflake IDs are 64 bits, which is most than JavaScript supports as an integer. Therefore, they must be processed as a string, even though they are entirely numeric.[2]

Usage

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

Discord also uses snowflake IDs, with their epoch set to the first second of the year 2015.[5]

Instagram uses a modified version of the format, with 41 bits for a timestamp, 13 bits for a shard ID, and 10 bits for a sequence number.[6]

See also

References

  1. ^ "twitter-archive/snowflake at b3f6a3c6ca". October 1, 2012. Retrieved January 18, 2021.
  2. ^ Siegler, MG (October 19, 2010). "Twitter's Snowflake Project To Update Tweet IDs Really Is More Like A Blizzard Now". TechCrunch. Retrieved January 18, 2021.
  3. ^ King, Ryan (June 1, 2010). "Announcing Snowflake". blog.twitter.com. Twitter. Retrieved January 18, 2021.
  4. ^ Siegler, MG (October 12, 2010). "Tweet IDs About To Get Jumbled In A Blizzard As Snowflake Is Set To Roll Live". TechCrunch. Retrieved January 18, 2021.
  5. ^ "API Reference". Discord Developer Portal. Discord. Retrieved January 18, 2021.
  6. ^ "Sharding & IDs at Instagram". Instagram Engineering. May 2, 2016. Retrieved January 18, 2021.

External links