4 ms·
For those wondering why not use UUID, most uuid implementation are guaranteed to be unique only when running a single machine. When working on loads of servers
by bytesandbots 11y ago
For those wondering why not use UUID, most uuid implementation are guaranteed to be unique only when running a single machine. When working on loads of servers without putting any load on a central resource, you can not rely on either uuid or sequential.
- tolmasky 11y agoUUID v4 seems to be based on random numbers, so should be "as good" as whatever scheme they were trying to hand roll here. Additionally, the uuid npm library uses crypto.randomBytes, which is cryptographically secure. https://github.com/broofa/node-uuid https://github.com/broofa/node-uuid
- mmalone 11y agoThe biggest problem is that they take up a lot of space. Plus you have to find a good library and vet it (there's nothing in the standard library). Or just write 10 lines of straightforward code. If you go and look at node-uuid commit history it, too, used Math.random() back in the day.
- mrighele 11y agoThis is true for UUID version 4, which is completely random. There are variant that use host-specific information in the process (in fact version 4 is the only one not doing it). [1] This said, I see that often only v4 is implemented, so maybe there are issue with the other variants. [1] https://en.wikipedia.org/wiki/Universally_unique_identifier https://en.wikipedia.org/wiki/Universally_unique_identifier