Profile Image
snaprecruit16

TOMCAT - running hot and taking high CPU

Need help to identify what needs to be fixed on the app side as its taking too much CPU and we have to restart every 24 hours 

top - 21:47:16 up 2 days,  8:03, 12 users,  load average: 11.58, 9.94, 9.12

Tasks: 258 total,   2 running, 256 sleeping,   0 stopped,   0 zombie

%Cpu(s): 99.2 us,  0.3 sy,  0.0 ni,  0.3 id,  0.0 wa,  0.0 hi,  0.1 si,  0.0 st

MiB Mem :  23862.2 total,    295.9 free,  21103.6 used,   2462.7 buff/cache

MiB Swap:   4096.0 total,   1255.5 free,   2840.5 used.   2439.0 avail Mem

    PID USER      PR  NI    VIRT    RES    SHR S  %CPU  %MEM     TIME+ COMMAND                                                                                                                                       

  44293 tomcat    20   0   19.9g  14.5g  15020 S 394.4  62.3   1452:05 java                                                                                                                                          

  57768 root      20   0       0      0      0 I   1.3   0.0   0:17.04 kworker/2:0-events                                                                                                                            

  10011 mysql     20   0 9839956   5.5g  13144 S   1.0  23.8  96:51.09 mariadbd                                                                                                                                      

  26628 ubuntu    20   0   15592   4068   3532 S   0.7   0.0   0:03.68 sshd                                                                                                                                          

  64407 root      20   0       0      0      0 I   0.3   0.0   0:54.74 kworker/3:1-events                                                                                                                            

  67423 ubuntu    20   0   10856   3332   2576 R   0.3   0.0   0:01.02 top                                                                                                                                           

  67452 ubuntu    20   0    8276   3904   2232 S   0.3   0.0   0:02.85 htop                                                                                                                                          

      1 root      20   0  167380   8908   5488 S   0.0   0.0   0:13.09 systemd                                                                                                                                       

      2 root      20   0       0      0      0 S   0.0   0.0   0:00.03 kthreadd                                                                                                                                      

      3 root       0 -20       0      0      0 I   0.0   0.0   0:00.00 rcu_gp                                                                                                                                        

      4 root       0 -20       0      0      0 I   0.0   0.0   0:00.00 rcu_par_gp                                                                                                                                    

      5 root       0 -20       0      0      0 I   0.0   0.0   0:00.00 slub_flushwq                                                                                                                                  

      6 root       0 -20       0      0      0 I   0.0   0.0   0:00.00 netns                                                                                                                                         

      8 root       0 -20       0      0      0 I   0.0   0.0   0:00.00 kworker/0:0H-events_highpri                                                                                                                   

     10 root       0 -20       0      0      0 I   0.0   0.0   0:00.00 mm_percpu_wq                                                                                                                                  

     11 root      20   0       0      0      0 S   0.0   0.0   0:00.00 rcu_tasks_rude_                                                                                                                               

     12 root      20   0       0      0      0 S   0.0   0.0   0:00.00 rcu_tasks_trace                                                                                                                               

     13 root      20   0       0      0      0 S   0.0   0.0   0:04.67 ksoftirqd/0                                                                                                                                   

     14 root      20   0       0      0      0 R   0.0   0.0   0:20.71 rcu_sched                     


Report URL - https://fastthread.io/my-thread-report.jsp?p=c2hhcmVkLzIwMjMvMTEvMjEvdGhyZWFkLmxvZy0tMy00Ni0yOQ==

    Please Sign In or to post your comment or answer

    Profile Image

    Ram Lakshmanan

     Inorder to accurately point the lines of code causing the CPU spike, you need to analyze not only thread dumps but also 'top -H -p {PID}' command output, where {PID} is your Java application's process Id which is experiencing CPU spike. When you issue this ‘top’ command with given arguments, it will list all the threads running in the application and amount of CPU each one of the thread consume. Once you have both the data, you can identify high CPU consuming thread and lines of code they are executing.

     

     You can use the open source yCrash script which will capture 360-degree application level artifacts (like GC logs, 3 snapshots of thread dumps, heap dumps) and system level artifacts (like top, top -H, netstat, vmstat, iostat, dmesg, diskusage, kernel parameters...). Once you have these data, either you can manually analyze them or upload it to yCrash tool. Tool analyzes all these dataset and generates an instant root cause analysis report pointing out exact line of code causing the CPU spike. Here is more detailed information on how to diagnose high CPU spike.

    Got something else on mind? Post Your Question