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

go slaytherelics: add cache to AuthenticateRedis path #25

Merged
merged 2 commits into from
Oct 23, 2024

Conversation

zdylag
Copy link
Contributor

@zdylag zdylag commented Oct 20, 2024

This is one of the hottest paths in the service, since each request ends up running a bcrypt operation (which is intentionally very expensive).

This is to compare the supplied token to the hashed version stored in redis. This token is actually an oauth token returned from when we previously authenticated with twitch (and not a user password or secret).

Given this, caching these timebounded token values feels pretty okay and will reduce load on the server by maybe 90% if the profile is to be believed.

We currently use sync.Map in a few places, which can be convenient
but has the notable downside of no type information. As a developer
this is pretty hard to interact with, and it can be an easy source of bugs.

Wrapping these in a typed wrapper does not really change anything
about the underlying behavior, but should make it a bit easier for us
humans.
This is one of the hottest paths in the service, since each request ends up running a bcrypt operation (which is intentionally very expensive).

This is to compare the supplied token to the hashed version stored in redis. This token is actually an oauth token returned from when we previously authenticated with twitch (and not a user password or secret).

Given this, caching these timebounded token values feels pretty okay and will reduce load on the server by maybe 90% if the profile is to be believed.
@zdylag zdylag force-pushed the zachdylag/CacheTokenRevalidation branch from d04ce5c to ca5574f Compare October 20, 2024 01:42
@MaT1g3R MaT1g3R merged commit 8e54071 into Spireblight:master Oct 23, 2024
1 check passed
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

Successfully merging this pull request may close these issues.

2 participants