Skip to content

Fix performance issues with many offline sessions - #15463

Merged
hmlnarik merged 1 commit into
keycloak:mainfrom
hmlnarik:13340-perf-issues-with-many-offline-sessions
Nov 15, 2022
Merged

hmlnarik merged 1 commit into
keycloak:mainfrom
hmlnarik:13340-perf-issues-with-many-offline-sessions

Conversation

@hmlnarik

Copy link
Copy Markdown
Contributor

@hmlnarik hmlnarik added kind/bug Categorizes a PR related to a bug area/storage Storage layer — JPA entities, database schemas, Liquibase migrations, caching labels Nov 11, 2022
@hmlnarik hmlnarik self-assigned this Nov 11, 2022

@sguilhen sguilhen left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks @hmlnarik . Only one comment that doesn't really prevent merging this.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor issue: the sentence doesn't look finished, seems like " are loaded" is missing here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, well spot. Fixed in the new commit

@hmlnarik
hmlnarik force-pushed the 13340-perf-issues-with-many-offline-sessions branch from 0b7e317 to 11eb952 Compare November 11, 2022 12:54
@martin-kanis

Copy link
Copy Markdown
Member

Thanks for the PR. I have been thinking about this a bit and here are my thoughts:
Should we be worried about reintroducing IN-clause which was removed in last performance optimization attempt? If the userSessionsIds set used in IN-cause gets too big, performance will be probably bad. However, I think we should be OK because userSessionIds size should be reasonable. There are these use-cases:

  • load user session by user (not limited by first,max parameters as it is called with first=0, max=null, but limited by number of user session which user can has. Not sure if this can be a high number in real scenarios. Maybe yes, if someone creates many offline user sessions for a user by i.e password grant type)
  • load user sessions by client (this can be a high number but it is called only from services and endpoint is limiting max result size -- 100 by default)
  • load user sessions by interval - IN clause not used and method is called only from pre-loading

@hmlnarik What are your thoughts on this?

@hmlnarik

Copy link
Copy Markdown
Contributor Author

@hmlnarik What are your thoughts on this?

Thank you for the reply. These are exactly the arguments why I am in favour of introducing the IN clauses for the cases when the session is known in advance while keeping the interval for preloading, and this PR should reflect it.

@mhajas mhajas left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR!

@hmlnarik
hmlnarik merged commit 556146f into keycloak:main Nov 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/storage Storage layer — JPA entities, database schemas, Liquibase migrations, caching kind/bug Categorizes a PR related to a bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Performance Issues with many offline sessions

4 participants