Skip to content

congerh/snowflake

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Snowflake

A Java program for generating unique ID numbers based on Twitter's Snowflake

ID is composed of:

  • time - 41 bits (millisecond precision w/ a custom epoch gives us 69 years)
  • configured machine id - 10 bits (5 bits datacenterId + 5 bits workerId) - gives us up to 1024 machines
  • sequence number - 12 bits - rolls over every 4096 per machine (with protection to avoid rollover in the same ms)

Usage

IdGenerator.getInstance().generateId();

About

A Java program for generating unique ID numbers

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages