Understand the TSID structure
masterA TSID (Time-Sorted ID) is a 64-bit integer composed of two main parts:
- Time component (42 bits): Milliseconds since 2020-01-01 00:00:00 UTC. This allows for ~69 years of usage in a signed 64-bit integer, or ~139 years in an unsigned field.
- Random component (22 bits): Split into:
- Node ID: Defaults to 10 bits (1,024 nodes), but is adjustable from 0 to 20 bits.
- Counter: The remaining bits (e.g., 12 bits if node is 10 bits), allowing for a specific number of TSIDs per millisecond (e.g., 4,096).
The time component can be slightly ahead of system time to maintain monotonicity and generation speed.