Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using shortid on many clients. #114

Open
hifall opened this issue Apr 5, 2018 · 3 comments
Open

Using shortid on many clients. #114

hifall opened this issue Apr 5, 2018 · 3 comments

Comments

@hifall
Copy link

hifall commented Apr 5, 2018

We have an SaaS app where many (potentially thousands) of client SPA's (Single Page Application) issue requests to the server.

In order to filter duplicate requests:
1 each request hits the server with an ID;
2 each time a request comes in, the server checks the request's ID -- if processed, simply ignore; otherwise proceed as usual;

Is shortid good for this purpose? How likely 2 or more SPA instances generate the same ID using shortid?

Thanks!

@yentsun
Copy link

yentsun commented Apr 15, 2018

@hifall for request id generation you can try generators with random part as server instance id and predictable (increment) part as request number:

  • hyperid (ids like ODI2YmQ3ZDktNzM4Ni00ZTA0LWE/42)
  • trid (prettier ids like pref.GtxXQ.42, with customizable prefix and length)

This way you are safe from request id collisions.

@hifall
Copy link
Author

hifall commented May 13, 2018

Thanks @yentsun, will check the links out shortly!

@ai
Copy link
Collaborator

ai commented Jul 8, 2018

Just use Nano ID. It is less predictable and has longer ID.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants