Reputation: 43
I've been attempting to containerize a Java application with Docker. When I have the container run this process as a user other than root, CPU usage goes to 100% and stays there. However, with root, it is much more well behaved, sitting around 2%.
# docker run -d -p 8006:8006 -u root --name root app:latest
# docker run -d -p 8007:8006 -u nonroot --name nonroot app:latest
# ps aux | grep java
root 26537 9.2 4.1 174800 115636 ? Sl 10:14 0:02 /opt/app/jvm16/bin/java -Xmx128M -Xms128M […]
nonroot 26808 94.8 6.2 202744 175368 ? Sl 10:15 0:08 /opt/app/jvm16/bin/java -Xmx128M -Xms128M […]
The application functions identically with either root or a non-root user (it's not hung). But if I run this same application on a real (not inside a container) server, the CPU usage is fine for either root or non-root, hinting at a container-related cause.
Nothing (that I could find) on the Docker host lends insight, and java dumps inside the container don't point me to anything.
My question is: what could be an explanation for this?
Upvotes: 4
Views: 1271
Reputation: 719576
My question is: what could be an explanation for this?
One possible explanation is that the application is repeatedly retrying something that works when the JVM is run as root
and fails when tun as a normal user; i.e. it is a combination of a poorly designed application and a permission problem.
I would try the following to try to figure out what is happening:
jstack
to see what threads are active and what they are doing. If the CPU is 100% and is is the JVM using the CPU, then there should be active threads.strace
to see what syscalls the JVM is doing.Upvotes: 4