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

Fix OOM when running Keycloak in DevMode #41833

Closed
wants to merge 1 commit into from

Conversation

fedinskiy
Copy link
Contributor

Fixes #41813

@fedinskiy fedinskiy marked this pull request as draft July 11, 2024 14:04
@fedinskiy fedinskiy marked this pull request as ready for review July 11, 2024 14:13
@fedinskiy
Copy link
Contributor Author

@sberyozkin you were interested in checking this one, IIRC

@sberyozkin
Copy link
Member

Thanks @fedinskiy, sure, I'd like to check on my laptop the difference, will get back to you asap

@@ -110,7 +110,7 @@ public class DevServicesConfig {
/**
* The `JAVA_OPTS` passed to the keycloak JVM
*/
@ConfigItem
@ConfigItem(defaultValue = "-XX:MetaspaceSize=96M -XX:MaxMetaspaceSize=256m -XX:+UseParallelGC -XX:GCTimeRatio=4 -XX:AdaptiveSizePolicyWeight=90")
Copy link
Member

Choose a reason for hiding this comment

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

I would expect the default values of the container to allow Keycloak to run?

If we have a problem there, we should probably report it to the Keycloak team?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

These values allow keycloak to run, but it may consume to much memory.

I presume, that they use defaults, which are good for their intended use case (long running containers with many connections), but are not optimal for devmode use case (containers are being spin up often, but for short time and with a single local client)

Copy link
Member

@sberyozkin sberyozkin Jul 12, 2024

Choose a reason for hiding this comment

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

@gsmet FYI, please see #41426, feedback from the Keycloak team is that the new GC policy is now used in Keycloak 25, with the advice being to set the limits at the (Quarkus) KC devservice level but that is hard to do right without impacting some systems. These suggested default properties are the ones which were used in KC 24 and they worked for all type of systems

Copy link
Member

@sberyozkin sberyozkin Jul 12, 2024

Choose a reason for hiding this comment

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

I wonder, instead of trying to deal with all of these advanced memory management properties by default, should we document that you may have to set these or those properties in memory constrained environments ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@sberyozkin what are the downsides of implementing this change?

As I see it, it makes life easier for some of our users and doesn't make things worse for anybody. Putting this into documentation means, that some of the users have to do it themselves and spend more time and effort. Am I missing something?

Copy link
Member

@sberyozkin sberyozkin Jul 12, 2024

Choose a reason for hiding this comment

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

@fedinskiy Sorry for the delay, I'm a little bit concerned that we'll put the properties and miss out on whatever happens in Keycloak around the GC management going forward, which may for example benefit unconstrained systems. My understanding that the problem happens only on the QE system so far.

But, it would make sense IMHO to see if trying to control the limits explicitly can work and what difference it can make. Can you please ping @mabartos for the extra guidance and try to find the HEAP limits for this system as suggested at https://www.keycloak.org/server/containers#_specifying_different_memory_settings ?
Have a look please in the next week or so

Copy link
Contributor

Choose a reason for hiding this comment

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

I've created a new PR for this with all the explanations: #43601

Copy link
Member

Choose a reason for hiding this comment

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

Thanks @mabartos

@sberyozkin
Copy link
Member

Hey @fedinskiy, thanks for the effort here, let me close this PR for now as #43601 replaces it, we can revisit if necessary, thanks again

@sberyozkin sberyozkin closed this Sep 30, 2024
@quarkus-bot quarkus-bot bot added the triage/invalid This doesn't seem right label Sep 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/oidc triage/invalid This doesn't seem right
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Keycloak container consumes too much memory in devmode
4 participants