BSON's 12-byte ObjectId type, constructed using: a 4-byte value representing the seconds since the Unix epoch, a 3-byte machine identifier, a 2-byte process id, and a 3-byte counter, starting with a random value.
BSON's 12-byte ObjectId type, constructed using: a 4-byte value representing the seconds since the Unix epoch, a 3-byte machine identifier, a 2-byte process id, and a 3-byte counter, starting with a random value.
The implementation is adopt from ReactiveMongo.
64-bit ID generator.
Abstract Object Id type.
64 bit ID generator based on Twitter Snowflake.
64 bit ID generator based on Twitter Snowflake. An id is composed of: time - 41 bits (millisecond precision with a custom epoch gives us 69 years) configured worker id - 10 bits - up to 1024 workers/threads/machines sequence number - 12 bits - rolls over every 4096 per worker (with protection to avoid rollover in the same ms)
You should use NTP to keep your system clock accurate. Snowflake protects from non-monotonic clocks, i.e. clocks that run backwards. If your clock is running fast and NTP tells it to repeat a few milliseconds, snowflake will refuse to generate ids until a time that is after the last time we generated an id. Even better, run in a mode where NTP won't move the clock backwards.