Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

OpenMRS is written in Java programming language, Even though Java is a very powerful language its quite popular for these kinds of drawbacks: high resource usage (high CPU utilisation, high RAM usage) because of its design. So in this case to exactly identify the high CPU usage issues within the system, first it would be better to understand the following things as a domain knowledge.

...

A high CPU problem is defined by an observation of one or many Java VM processes consuming excessive CPU utilization from your physical host(s). Excessive CPU can also be described by an abnormal high CPU utilization vs. a known & established baseline. Ex: if the average CPU utilization of your Java VM under peak load condition is 40% then excessive CPU threshold can be set around 80%.

A typical Java VM process contains several Java Threads, some waiting to do work and others currently executing tasks. The # of Threads can be very low in the event of a single Java program and very high for Java EE enterprise platforms processing heavy concurrent transactions.

In order to understand and identify the source of high CPU of one or many of your Java processes, you will need to understand and perform a full breakdown of all Threads of your Java VM so you can pinpoint the biggest contributors. This analysis exercise can be visualized as per below diagram.

...

  • run top -H (on *nix terminal)
  • get PID of the thread with highest CPU
  • get stack dump of java process: jstack <Chosen PID> : Please  It is highly recommended to take more than 1 thread dump, Please see below for more detailed guide on getting multiple dumps.
  • convert the chosen PID to HEX : 0x + http://www.binaryhexconverter.com/decimal-to-hex-converter
  • in stack dump look for thread with the matching HEX PID.

...