Snowflake ID Generator
Snowflake ID is a distributed ID generation algorithm developed by Twitter, capable of generating unique 64-bit IDs in distributed systems.
Algorithm Principle
A Snowflake ID is a 64-bit integer composed of the following parts:
- Timestamp (41 bits): Millisecond-level timestamp, usable for 69 years
- Datacenter ID (5 bits): Supports 32 datacenters
- Machine ID (5 bits): Supports 32 machines per datacenter
- Sequence Number (12 bits): Can generate 4096 IDs per millisecond
Usage
- Set Machine ID (0-1023)
- Set Datacenter ID (0-31)
- Click "Generate ID" button to generate a single ID
- Click "Generate Multiple IDs" button to batch generate IDs
- View detailed information of generated IDs
Features
- High Performance: Can generate 4096 IDs per millisecond
- Distributed: Supports multi-machine, multi-datacenter deployment
- Ordered: IDs are incremented by time
- Unique: Ensures ID uniqueness in distributed systems
Use Cases
- Database primary key generation
- Unique identifiers in distributed systems
- Order number generation
- Message IDs in message queues