Uploaded image for project: 'Server Deployments and Scale'
  1. Server Deployments and Scale
  2. SCALE-37

Provide "auto heap size" option for docker images under Java11

XMLWordPrintable

    • Icon: Suggestion Suggestion
    • Resolution: Unresolved
    • None
    • None
    • Environment - Docker
    • None
    • Our product teams collect and evaluate feedback from a number of different sources. To learn more about how we use customer feedback in the planning process, check out our new feature policy.

      Currently, our Docker images will always launch the JVM in the container using Xmx and Xms flags, with a default value if the user doesn't not specify the appropriate env vars.

      However, this doesn't give the JVM any chance to make an informed decision on its own, using the container's cgroups memory allocation. Since Java10, The JVM will auto-detect the cgroups allocation and allocate max heap accordingly - unless you override that with Xmx and Xms.

      My suggestion is to provide a new environment variable, JVM_AUTO_MEMORY for example, which will omit the -Xmx and -Xms command line arguments to the JVM, and let the JVM pick its own value based on the container's constraints. Ideally, this would be the default behaviour, but we need to support the existing Xmx and Xms defaults.

      For extra points, add another env var to support the -XX:MaxRAMPercentage flag, which overrides how much of the container's available memory will be allocated to the heap (it seems to default to 50%).

      The result of this change would be to manage the JVM's memory sizing via container restrictions, rather than specifying it in the JVM. This is particularly compelling for Kubernetes environments, where admins want to allocate resources to the pods' containers, and have the JVM honour that, without having to dive down into Xmx and Xms configuration.

              Unassigned Unassigned
              kmacleod Kenny MacLeod
              Votes:
              4 Vote for this issue
              Watchers:
              5 Start watching this issue

                Created:
                Updated: