2

My application setup: 4 docker containers setup by docker-compose: myapplication (tomcat, jersey application), kafka, postgres, zookeeper.

I need to know the CPU usage of tomcat container.

1, I used JavaMeloday to get % System CPU 93.36, more details.

2, I used docker stats <docker id> to get that CPU % is 356% at the same time with % System CPU 93.36 by JavaMelody.

In my machine, there are 8 cores. why the numbers in 1 and 2 are different? How to explain them?

Thanks

BAE
  • 8,550
  • 22
  • 88
  • 171

1 Answers1

1

As mentioned in moby/moby issue 26711:

800% is correct here, which is a standard notation for telling that 8 cores are 100% in use.

So 356% means the docker container processes (not just the java Tomcat) uses almost 4 of the 8 cores.

As opposed to Javamelody, used in "A Step-by-Step Guide to Tomcat Performance Monitoring", which monitors the Java application through JMX, and reports more: from "Java – monitoring cpu and system load of multi-threaded application via OperatingSystemMXBean", that value is an aggregate for all cores).

The issue is: docker stats and javamelody don't monitor the activity at exactly the same time, and could report (and aggregate) different activity peaks.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • so, `% System CPU 93.36` means 93.36% of 8 cores OR 93.36% of ONE core in JavaMelody? – BAE Feb 28 '18 at 21:50
  • @BAE From what I read, all cores. I have edited the answer accordingly, with a link. – VonC Feb 28 '18 at 22:03
  • Thanks. I am doing some performance testings on tomcat. can I trust the figure (93.36%)? I doubt why it is so high. – BAE Feb 28 '18 at 22:07
  • @BAE Does it remains high consistently? – VonC Feb 28 '18 at 22:08
  • No, when I started using ab (apache bench) to do testings. In this case, it seems that it is reliable? – BAE Feb 28 '18 at 22:10
  • @BAE as a snapshot, it is reliable. But, as for any snapshot, it varies in time depending on the activity measured for that snapshot. – VonC Feb 28 '18 at 22:12
  • I am still confused. 93.36% is for tomcat application OR all processes running on my computer? – BAE Mar 01 '18 at 16:39
  • @BAE as exlpained in https://bmwieczorek.wordpress.com/2015/11/02/java-monitoring-cpu-and-system-load-of-multi-threaded-application-via-operatingsystemmxbean/, "System CPU" means "for the whole system with range [0.0,1.0] where 0.0 means that all CPUs were idle, 1.0 means that all CPUs were actively running 100% of the observed time". – VonC Mar 01 '18 at 16:42
  • I am confused by `whole system`. You mean it is all processes running on my computer? – BAE Mar 01 '18 at 16:45
  • @BAE yes, all machine. – VonC Mar 01 '18 at 16:47