Sonyflake is a distributed unique ID generator inspired by Twitter's Snowflake.
Sonyflake addresses the need for generating unique IDs across distributed systems by allocating bits differently than Snowflake to optimize for lifetime and performance in multi-host environments. The default configuration uses 39 bits for time in 10-millisecond units, 8 bits for sequence numbers, and 16 bits for machine IDs. This bit assignment extends the ID lifetime to approximately 174 years and supports up to 65,536 machines, though it trades off per-instance generation rate, capping at 256 IDs per 10 milliseconds on a single instance. The tool allows customization of bit assignments and time units to adjust the balance between lifetime and generation rate according to specific needs.
Sonyflake suits projects requiring distributed ID generation across many hosts where extended lifetime matters more than maximum throughput per instance. It works well in cloud environments like AWS, where the tool provides utilities to derive machine IDs from EC2 instance metadata and private IP addresses. The configurable bit allocation makes it adaptable to scenarios where the default trade-offs do not match requirements. For applications needing higher generation rates on a single host, the tool supports running multiple instances in parallel using goroutines.
The project maintains active engagement with practical deployment scenarios, evidenced by dedicated support for AWS VPC and Docker environments through utility packages. The codebase includes example implementations demonstrating real-world usage patterns. Configuration flexibility is a core design principle, with all major parameters—sequence bits, machine ID bits, time unit, and start time—exposed for customization while maintaining validation to prevent invalid configurations.