6 ms·
If you generate a sufficiently long random number then the probability of duplicates easily becomes lower than the probability of duplicates in a counter scheme
by mikeash 11y ago
If you generate a sufficiently long random number then the probability of duplicates easily becomes lower than the probability of duplicates in a counter scheme due to a bug or hardware fault. And "sufficiently" long doesn't require a novel. 128 bits is sufficient for just about everything, and 256 bits is enough for everything.
Why bother with a complicated atomic ID operation (and that's going to be fun to scale, too) when a relatively short string of random bits will do the job?