-
Notifications
You must be signed in to change notification settings - Fork 46
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
FORMS-1677: add user caching #1577
base: main
Are you sure you want to change the base?
FORMS-1677: add user caching #1577
Conversation
To reduce the number of hits to the db for user (login user and current user) add a caching layer. Signed-off-by: Jason Sherman <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that as a team we need to discuss this sort of thing before work starts on it.
I have no idea when we are going to have a prioritized list of tasks, so got to work on something. Performance is an issue and has been raised by clients. Some analysis has been done on this (no metrics, but when are we going to get metrics?) so good thing as any to get cracking on. This isn't a "look at the files and approve" PR. At least there is something to kick around and test out. |
This comment has been minimized.
This comment has been minimized.
Signed-off-by: Jason Sherman <[email protected]>
Signed-off-by: Jason Sherman <[email protected]>
Release 2dcf1ae deployed at https://chefs-dev.apps.silver.devops.gov.bc.ca/pr-1577 |
To reduce the number of hits to the db for user (login user - parsed token + db id) add a caching layer.
Cache the login user (parsed token + db fields). Caching is limited to 5 minutes - same as our token.
A few important things happen before we read from the cache:
If we have a valid token, we can then check the cache. If we get a cache hit, we check to see that the cache version matches the token (token may have been refreshed). If that cache hit is stale, then we discard it and do the normal refresh and hydration of the login user and then cache it.
The login user (current user) is called on nearly all endpoints and currently invokes 2 db hits. Short term caching will reduce db load and therefore improve performance. This caching strategy is not aggressive and has safeguards to prevent returning an invalid user.
This relates to #1579 where we remove forms from the current user and use explicit form queries instead of always making those 2 db hits.
Description
Type of Change
feat (a new feature)
perf (change to improve performance)
Checklist
Further comments