dylang / shortid

Short id generator. Url-friendly. Non-predictable. Cluster-compatible.

Home Page:https://www.npmjs.org/package/shortid

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

I need to use shortid.worker(0-16) for each instance in the same physical machine or for any instance in the cloud?

kamilml opened this issue · comments

Hi guys. For exmaple, if I am using some instances of my app in a cloud service like now.sh (I am not sure if this is an only one server or different servers for each instance) with 20 instances in total.
I have to pass shortid.worker(0-16) ? Then I just can numbered 17 instances.

Thats an interesting question, I never even considered that. I was thinking maybe one way to get around the duplicate id issue would be to provide a single api that generates an id? This way the id is always being generated from the same source. Not sure if this would work, just thinking out loud.

Just use Nano ID with hardware random generator. Because of hardware random generator, Nano ID doesn't need to set worker ID.