Reputation: 3064
we are running openjdk:11-slim based docker containers in AWS. We usually use two instance types. One with 1G, the other with 2G of available memory. On the 1G instances, I have started to constraint the heap size using these args:
-XX:MaxRAM=1g -XX:MaxRAMPercentage=30
I would like to constrain non-heap as well. It is a Spring Boot application and in Spring Boot Admin it currently looks like this (running default):
As you can see, 1.33 GB Max wouldn't even work because there is only 1G of total memory. Ideally, the non-heap should be constraint to stay within 30% as well. Which JVM args can I use to size the non-heap memory?
I have investigated a little bit and on this instance, about 30% of 1G total RAM are already used for non application related processes (third column is the percentage of total memory).
3663 root 4.6 /usr/bin/python2.7 /usr/bin/aws logs push --config-file /etc/awslogs/awslogs.conf --additional-configs-dir /etc/awslogs/config
3430 root 4.1 /usr/bin/dockerd --storage-driver devicemapper --storage-opt dm.thinpooldev=/dev/mapper/docker-docker--pool --storage-opt dm.use_deferred_removal=true --storage-opt dm.use_deferred_deletion=true --storage-opt dm.fs=ext4 --storage-opt dm.basesize=100G
2949 healthd 3.5 puma 2.11.1 (tcp://127.0.0.1:22221) [healthd]
3021 root 2.6 /usr/bin/python2.7 /opt/aws/bin/cfn-hup
3437 root 2.2 containerd --config /var/run/docker/containerd/containerd.toml --log-level info
4867 root 2.1 docker logs -f f82ef403ef45
4831 root 2.0 docker wait f82ef403ef45
3501 root 1.9 docker events
3322 root 1.7 /sbin/dmeventd
16976 root 0.7 sshd: ec2-user [priv]
2280 root 0.6 /usr/bin/amazon-ssm-agent
Upvotes: 3
Views: 10843
Reputation:
You cannot constraint off-heap memory, otherwise the application would crash. When direct memory is allocated, it is always needed, so denying it is the same as OutOfMemoryError
.
You can limit metaspace size with -XX:MaxMetaspaceSize=
.
You can reduce the amount of memory used by the JIT compiler to store compiled methods, therefore potentially reducing compilation, with -XX:ReservedCodeCacheSize=
.
Upvotes: 6