finds.dev← search

// the find

yitter/IdGenerator

★ 3,186 · C · MIT · updated Apr 2025

💎多语言实现,高性能生成唯一数字ID。 💎优化的雪花算法(SnowFlake)——雪花漂移算法,在缩短ID长度的同时,具备极高瞬时并发处理能力(50W/0.1s)。 💎原生支持 C#/Java/Go/Rust/C/JavaScript/TypeScript/Python/Pascal 多语言,提供其它适用于其它语言的多线程安全调用动态库(FFI)。💎支持容器环境自动扩容(自动注册 WorkerId ),单机或分布式唯一IdGenerator。💎顶尖优化,超强效能。

A Snowflake ID variant that squeezes shorter IDs out of the same 64-bit space by using a 'drift' technique — when the sequence overflows in a millisecond, it borrows sequence numbers from future milliseconds rather than blocking. Aimed at distributed systems that need numeric primary keys smaller than standard Snowflake, with native implementations in 10+ languages. The primary audience is backend developers building distributed systems who find GUIDs too fat and standard Snowflake IDs too long for JS's Number type.

- The drift algorithm is the real differentiator: instead of spinning and waiting when sequence bits overflow, it advances the timestamp counter, keeping throughput high without clock dependency. The 2-5x perf improvement over classic Snowflake is credible given this.

- Time-rollback handling is thought through — it uses pre-reserved sequence slots (positions 1-4) to generate IDs during rollback windows rather than throwing an exception or blocking. This is the #1 operational headache with Snowflake and most implementations just crash.

- The multi-language coverage is genuine native ports (not FFI wrappers calling a C core), meaning you get idiomatic code in C#, Java, Go, and Rust without a shared-library dependency chain.

- WorkerId auto-registration via Redis is included for k8s horizontal scaling — the most annoying operational problem with any Snowflake implementation is WorkerId coordination, and they've actually shipped a solution instead of leaving it as 'exercise for the reader'.

- The README is almost entirely in Chinese with minimal English translation, which will be a wall for most Western teams despite the code itself being readable. The algorithm documentation especially suffers.

- WorkerId auto-registration requires Redis — there's no etcd, Consul, or ZooKeeper alternative. If your stack doesn't already have Redis, you're adding infrastructure just to solve worker coordination.

- Last commit was April 2025, and several language implementations (PHP, JavaScript, Python) rely on a prebuilt binary FFI library rather than native ports — those binaries haven't been updated in years and the PHP extension targets PHP 7.3/7.4/8.0 only.

- The 'drift' behavior means IDs are not strictly monotone within a millisecond under high load — they're monotone across time but the sequence can borrow from future timestamps. This breaks assumptions in any code that treats ID order as insertion order, and the docs don't flag this prominently.

View on GitHub →

// want more like this?

We dig through GitHub every week and send a few repos picked for what you actually care about — each with an honest take like this one.

Get finds in your inbox → Search again →