Hello,
I’m experiencing issues with Docker. When I create a container, it consumes 5-10 GB of RAM and consistently utilizes at least 100% of the CPU. I had the same Java applications running on another server without Docker, where they only consumed 1 GB of RAM and approximately 4-10% CPU each. Here are some additional details about my system:
Are you using resource constraints on the containers?
Java will use up to 1/4 of the memory for heap if you don’t set resource constraints. On old java versions, it even used to ignore the resource constraints and always went up to 1/4 of the host memory, even if a resource constraint was set (and resulted in the container being oom killed).
You should monitor the application to identify what’s actually needed and then set the resource constraints accordingly.
If you compare it to on host operation, you need to compare it to a host that has the exact same resources like your docker host.
Yes, I have applied resource constraints; however, this does not address the underlying issue that the containers consume a significant amount of RAM and CPU. It merely prevents excessive utilization of RAM and CPU, but as a result, the containers and their applications no longer run smoothly.
Given the provided details, there is not much I can say except: java can be tamed inside a container by monitoring and tweaking the resource constraints, and tweaking the jvm parameters.
I have found the problem. However, I still have a question about reserving the CPU utilization of each container. How can I deactivate this reservation?
Docker containers don’t reserve resources by default. If the CPU is used that is used by the application running inside it. If it is different without containers I don’t know why, but the reason is probably something that the application has to do differently. Maybe the reason is not Docker but the machine itself. I have seen apps working differently because of a different CPU and (possibly) CPU opimization module compatibility.
To tell you anything more we should know more about what you run and what the app does exactly, but you can try to run “top” in the container find out which process uses the CPU if there are more then one.