Randomizing Strings In A Microservices World

Tim Delaney timothy.c.delaney at gmail.com
Mon Dec 9 20:52:42 EST 2019


On Tue, 10 Dec 2019 at 12:12, Tim Daneliuk <info at tundraware.com> wrote:

> - 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.
>

10 digits is only 999999999. That's not a very big number. Forget
nanoseconds since the epoch, that won't currently give you seconds since
the epoch - let alone combining with any other identifier.

$ date '+%s'
1575942612

Tim Delaney


More information about the Python-list mailing list