dylang / shortid

Short id generator. Url-friendly. Non-predictable. Cluster-compatible.
https://www.npmjs.org/package/shortid
Other
5.74k stars 258 forks source link

Collision/ Duplicate Ids getting Generated In our Production with this module #150

Closed pssvenkatrao closed 5 years ago

pssvenkatrao commented 5 years ago

I am using the default setting shortid.characters("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-_"); shortid.generate().substring(0, 5); I am seeing the duplicate IDs generating and resulting in failure when I have short id as unique index while saving in DB.

We are running the code in 5 PODs in each of kubernetes clusters.. Please suggest.

ai commented 5 years ago
  1. shortid is deprecated. Use Nano ID.
  2. 5 symbols are not enough to prevent collisions in complex systems.
  3. Here is ID length and collisions calculator to choose the best length for you.