2 ms·
It sounds similar to Twitter's Snowflake? https://en.wikipedia.org/wiki/Snowflake_ID https://en.wikipedia.org/wiki/Snowflake_ID
by benoau 5mo ago
It sounds similar to Twitter's Snowflake?
https://en.wikipedia.org/wiki/Snowflake_ID https://en.wikipedia.org/wiki/Snowflake_ID
- yakkasean 5mo agoIt does look similar. I’m confused though how they coordinate sequence bits with only 2^10 (1024) workers. Surely they have more web servers than that, so sequence must be coordinated in a centralized way. Also, this is a 62 bit spec.
- benoau 5mo agoThere is source code available for it (although the repo's retired): https://github.com/twitter-archive/snowflake/blob/b3f6a3c6ca8e1b6847baa6ff42bf72201e2c2231/src/main/scala/com/twitter/service/snowflake/IdWorker.scala https://github.com/twitter-archive/snowflake/blob/b3f6a3c6ca... Basically one big server had a number of threads each requesting the next value in the sequence on that machine. The sequence only had to be unique to that machine and was just a counter of how many tweets since <last whole millisecond>. Tweets per millisecond per server was probably never a huge number, so they were able to share the 10 bits between datacenter id and that counter.