On Mon, 9 Dec 2019 21:38:43 -0600, Tim Daneliuk <i...@tundraware.com> wrote: > On 12/9/19 8:54 PM, Dennis Lee Bieber wrote: >> On Mon, 9 Dec 2019 18:52:11 -0600, Tim Daneliuk <i...@tundraware.com> >> declaimed the following: >> >>> - Each of these services needs to produce a string of ten digits >>> guaranteed to be unique on a per service instance basis AND to not >>> collide for - oh, let's say - forever :)s >>> >>> Can anyone suggest a randomization method that might achieve this >>> efficiently? >>> >>> My first thought was to something like nanonseconds since the epoch >>> plus something unique about the service instance - like it's IP? >>> (This is in a K8s cluster) - to see the randomization and >>> essentially eliminate the string being repeated. >>> >>> Ideas welcome .. >> >> Well, 10 digits is rather short, but studying >> https://en.wikipedia.org/wiki/Universally_unique_identifier might provide >> some ideas. > > For a variety of reasons the length of this string cannot exceed 10 > digits. It is believed that - in this application - the consumption > of values will be sparse over time. All I really need is a high > entropy way to select from among the billion possible values to > minimize the possibility of collisions (which require retry and time > we don't want to burn).
Just to be sure: you *are* aware that the "Birthday Paradox" says that if you pick your 10-digit strings truly randomly, you'll probably get a collision by the time of your 10**5th string . . . right? -- To email me, substitute nowhere->runbox, invalid->com. -- https://mail.python.org/mailman/listinfo/python-list