yitter/IdGenerator
Free💎多语言实现,高性能生成唯一数字ID。 💎优化的雪花算法(SnowFlake)——雪花漂移算法,在缩短ID长度的同时,具备极高瞬时并发处理能力(50W/0.1s)。 💎原生支持 C#/Java/Go/Rust/C/JavaScript/TypeScript/Python/Pascal 多语言,提供其它适用于其它语言的多线程安全调用动态库(FFI)。💎支持容器环境自动扩容(自动注册 WorkerId ),单机或分布式唯一IdGenerator。💎顶尖优化,超强效能。
About yitter/IdGenerator
IdGenerator is an optimized implementation of the Snowflake algorithm (Snowflake Drift) that generates shorter unique numeric IDs at higher speeds than traditional Snowflake. It natively supports multiple programming languages including C#, Java, Go, Rust, C, JavaScript, TypeScript, Python, Pascal, PHP, SQL, and Delphi, with additional languages supported via FFI. The algorithm achieves high throughput (500k IDs per 0.1 seconds with default configuration, up to 3000W IDs per second with tuning), handles time rollback gracefully, allows manual insertion of historical IDs, and supports container environment auto-scaling with automatic WorkerId registration (optional Redis dependency in K8s). It is designed for distributed systems, database primary keys, and scenarios requiring time-ordered unique IDs, with a lifespan of over 71,000 years under default settings.
Key Features
Pros & Cons
- Very high performance: up to 3000W IDs per second with tuning
- Generates shorter IDs than traditional Snowflake, saving storage
- Handles time rollback automatically without collision
- Multi-language support enables integration across diverse tech stacks
- No external dependencies for basic use (database, cache, etc.)
- Long lifespan: over 71,000 years before ID exhaustion
- Compatible with existing Snowflake systems for easy migration
- WorkerId must be globally unique; distribution management required outside K8s environments
- Performance tuning requires understanding of parameters (WorkerIdBitLength, SeqBitLength)
- Depends on system clock accuracy; extreme drifts may cause ID sequence issues (though algorithm handles limited rollbacks)
- Optional Redis dependency for automatic WorkerId registration in container environments