4

When we starts the keycloak container, it uses almost 700 MB memory right away. I was not able to find more details on how and where it is using this much memory. I have couple of questions below.

  1. Is there a way to find more details about which processes are taking more memory inside the container? I was looking into the file /sys/fs/cgroup/memory/memory.stat inside the container which didn't give much info.
  2. Is it normal for the keycloak container to use this much memory? Or we need to do any tweaking in the configuration file for better performance.

I would also appreciate if anyone has more findings which can be leverage to improve overall performance of the application.

sagun
  • 93
  • 1
  • 4
  • 1
    Checkout the keycloak version 17. It was rewritten to use quarkus.io and it's way better memory wise and boot startup... – Begui Feb 23 '22 at 12:55

1 Answers1

4

Keycloak is Java app, so you need to understand Java/Java VM memory footprint first: What is the memory footprint of the JVM and how can I minimize it?

If you want to analyze Java memory usage, then Java VisualVM is a good starting point.

700MB for Keycloak memory is normal. There is initiative to move Keycloak to Quarkus (https://www.keycloak.org/2020/12/first-keycloak-x-release.adoc), which will reduce also memory footprint - it is still in the preview, not generally available.

In theory you can switch to different runtime (e.g. GraalVM), but then you may have different issues - it isn't officialy supported setup.

IMHO: it'll be overengineering if you want to optimize your Keycloak memory usage; it is a Java app

Jan Garaj
  • 25,598
  • 3
  • 38
  • 59
  • 1
    so if we want to run keycloak on ec2 server do we need a RAM size for more than 1GB? i see that the docker container for keycloak crashes every now and then – sanketh s Apr 21 '22 at 10:20