Merged
Conversation
Some requests which trigger many database queries have been running very slowly. To help with this we activate the Hibernate "second-level" cache which persists between database transactions and is shared between threads. In simple local experiments this can increase the speed of fully cached requests by over 3x.
This reverts commit f50b06b.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Summary
Some requests which trigger many database queries have been running very slowly. To help with this we activate the Hibernate "second-level" cache which persists between database transactions and is shared between threads. The database entities chosen to be cached are
CorrespondenceMapsince a high number of these are accessed in the longest-running requests.Advantages
This change has shown to increase the speed of fully cached requests by over 3x. For example a request to
https://klass-dev-cache.intern.test.ssb.no/api/klass/v1/classifications/131/changes\?from\=0000-01-01now takes 22s where it takes 1m44s for instances without caching enabled.Disadvantages
Due to the caching being quite aggressive, changes to the cached objects in the database may not be shown to users. To mitigate this we have been selective about which DB entities are cached. The
CorrespondenceMapshould primarily be for historical data which won't receive updates, but we need to run a thorough User Acceptance Test to verify this.Other changes
Testing
Have run unit tests and all data integrity tests, as well as manual testing on the endpoints which have had performance problems.
Ref: DPMETA-1204