Very nice. This is based on Boundary's Erlang Flake ID service, more details of which are at <a href="http://boundary.com/blog/2012/01/12/flake-a-decentralized-k-ordered-unique-id-generator-in-erlang/" rel="nofollow">http://boundary.com/blog/2012/01/12/flake-a-decentralized-k-...</a>.<p>One thing I had to look up again was the definition of k-ordering: K-ordering gives <i>roughly</i> time-ordered id's down to the millisecond when sorted lexicographically. This is usually fine for most purposes but keep in mind it doesn't allow you to reason about causality between timestamps from different machines.<p>This also relies on your servers clocks to be in sync (something that should be happening anyway).
"So this allows for 2^16-1 unique IDs per millisecond per machine."<p>Technically thats per MAC not per machine. I've run into multiple NICs with duplicate MACs as has everyone else who's been in the game long enough.
Neat! I made one of these in Java a while back after reading the snowflake Twitter post (which has since been removed). Looks like Twitter has retired Snowflake: <a href="https://github.com/twitter/snowflake" rel="nofollow">https://github.com/twitter/snowflake</a><p><a href="https://github.com/mumrah/flake-java" rel="nofollow">https://github.com/mumrah/flake-java</a>
Simpleflake is a 64 bit alternative <a href="http://engineering.custommade.com/simpleflake-distributed-id-generation-for-the-lazy/" rel="nofollow">http://engineering.custommade.com/simpleflake-distributed-id...</a>