Flake: A Decentralized, K-Ordered Unique ID Generator in Erlang
blog.boundary.com
Flake: A Decentralized, K-Ordered Unique ID Generator in Erlang
1–10 of 18 posts
Re: Flake: A Decentralized, K-Ordered Unique ID Generator in Erlang
#2- Why [time, node id, seq] and not [time, seq, node id]? That would improve ordering if you have approximately equal load on each box.
- Isn't a 16 bit seq number overkill? Handing some of those bits to the unique ID would have made unique ID assignment easier. Duplicate MACs can and do exist (especially if you buy a lot of hardware from the same vendors).
- The quality of the ordering is going to be restricted by the quality of time synchronization within the cluster. Relying on NTP for this is OK, but experience suggests that a secondary monitoring system will be needed. Similarly, relying on monotonic time needs some care in system administration - care that could potentially be avoided with a different unique host ID assignment scheme.
Re: Flake: A Decentralized, K-Ordered Unique ID Generator in Erlang
#3Re: Flake: A Decentralized, K-Ordered Unique ID Generator in Erlang
#4Re: Flake: A Decentralized, K-Ordered Unique ID Generator in Erlang
#5Re: Flake: A Decentralized, K-Ordered Unique ID Generator in Erlang
#6Re: Flake: A Decentralized, K-Ordered Unique ID Generator in Erlang
#7A couple of questions about this: - Why [time, node id, seq] and not [time, seq, node id]? That would improve ordering if you have approximately equal load on each box. - Isn't a 16 bit seq number overkill? Handing some of those bits to the unique ID would have made unique ID assignment easier. Duplicate MACs can and do exist (especially if you buy a lot of hardware from the same vendors). - The quality of the orderi…
Would you rely on sub-millisecond synchronization between nodes _and_ an almost exact load amount?
In other words for a particular millisecond seq order is only relevant on that particular node, so node should come first.
Re: Flake: A Decentralized, K-Ordered Unique ID Generator in Erlang
#8For those interested, there is also Snowflake by Twitter on GitHub https://github.com/twitter/snowflake
Re: Flake: A Decentralized, K-Ordered Unique ID Generator in Erlang
#9A couple of questions about this: - Why [time, node id, seq] and not [time, seq, node id]? That would improve ordering if you have approximately equal load on each box. - Isn't a 16 bit seq number overkill? Handing some of those bits to the unique ID would have made unique ID assignment easier. Duplicate MACs can and do exist (especially if you buy a lot of hardware from the same vendors). - The quality of the orderi…
> Why [time, node id, seq] and not [time, seq, node id] Would you rely on sub-millisecond synchronization between nodes _and_ an almost exact load amount? In other words for a particular millisecond seq order is only relevant on that particular node, so node should come first.
It still seems to me that T_0,0,A (issued by node A at T_0 with seq number 0) would tend to come before T_0,1,B so putting the sequence number first does add some value. On the other hand, the ordering T_0,A,0 > Would you rely on sub-millisecond synchronization between nodes _and_ an almost exact load amount?
Not rely on. Absolutely not. Maybe it's better to go further, and make it more explicit that the IDs are K ordered. Say you could synchronize your host clocks reliably to a maximum delta of 512 ms, then you could chose a scheme like:
[ milliseconds >> 9, host id, milliseconds & 0x1ff, seq id ]
The value here is that you make it much harder for consumer of the IDs to make incorrect assumptions about the precision of their ordering. Basically taking away the temptation to make statements about their ordering with false precision, by making a simple sort only provide a meaningful ordering within the real available precision.
Re: Flake: A Decentralized, K-Ordered Unique ID Generator in Erlang
#10http://instagram-engineering.tumblr.com/post/10853187575/sha...