3 ms·
A Sonyflake ID is composed of 39 bits for time in units of 10 msec 8 bits for a sequence number 16 bits for a machine id
by abahlo 6y ago
A Sonyflake ID is composed of
39 bits for time in units of 10 msec
8 bits for a sequence number
16 bits for a machine id
- olalonde 6y agoWhy do the bits add up to 63 rather than 64?
- sjansen 6y agoJust a guess without reading the code, the unused bit is probably to avoid complications from signed integers. If the sign bit is never set, signed and unsigned integers can store the same data.
- lmilcin 6y agoPresumably to make them work with languages that don't recognize unsigned integers? For example Java...
- secondcoming 6y agoDoes this mean that using them in a multi-threaded context may produce duplicate ids? Edit: To answer my own question. No, although it does seem to limit your application to a single process with at most 256 threads, if I'm reading it correctly. > Sequence numbers are per-thread and worker numbers are chosen at startup via zookeeper (though that’s overridable via a config file). [0] [0] https://blog.twitter.com/engineering/en_us/a/2010/announcing-snowflake.html https://blog.twitter.com/engineering/en_us/a/2010/announcing...
- random5634 6y agoThis proves my point. 39 bits for time in 10 msec is something like 17x years. ULID runs through 10889 AD