3 ms·
If you need unique nanosecond, keep track of the previously generated one and increase it if necessary. Would require global lock or atomic stuff, but should be
by vbezhenar 3y ago
If you need unique nanosecond, keep track of the previously generated one and increase it if necessary. Would require global lock or atomic stuff, but should be good enough for practical uses.
- pyrale 3y agoOne benefit of UUID is that you don't need coordination. In coordinated systems, unique IDs are a non-issue.
- buster 3y agoIf you do that, just take some redis server and increment an integer every time you need a new number?
- marcus_holmes 3y agoor y'know, use the thing that was designed specifically for this case: UUID's
- hnlmorg 3y agoUUIDs are designed to solve a slightly different, albeit related, problem: where you don’t have synchronisation of the system as a whole. The solution the GP is solving is for systems that are synchronised and therefore generating a UUID is additional and unnecessary overhead.
- LAC-Tech 3y ago"Logical Physical Clocks" may be of interest. The timestamps are monotonic and don't require atomic clocks like in google spanner. HLC captures the causality relationship like logical clocks, and enables easy identification of consistent snapshots in distributed systems. Dually, HLC can be used in lieu of physical/NTP clocks since it maintains its logical clock to be always close to the NTP clock. Moreover HLC fits in to 64 bits NTP timestamp format, and is masking tolerant to NTP kinks and uncertainties. https://cse.buffalo.edu/~demirbas/publications/hlc.pdf https://cse.buffalo.edu/~demirbas/publications/hlc.pdf
- LeoNatan25 3y agoIf there are collisions seen, that means there would be lock contention at this critical section, thus not a “good enough” solution.