{"id":3018,"date":"2018-03-11T19:21:04","date_gmt":"2018-03-11T15:51:04","guid":{"rendered":"http:\/\/www.serveridol.com\/?p=3013"},"modified":"2018-03-11T19:21:04","modified_gmt":"2018-03-11T15:51:04","slug":"collecting-the-jvm-data-for-identifying-the-bottleneck","status":"publish","type":"post","link":"https:\/\/afaghhosting.net\/blog\/collecting-the-jvm-data-for-identifying-the-bottleneck\/","title":{"rendered":"Collecting the JVM data for identifying the bottleneck"},"content":{"rendered":"<p dir=\"ltr\" style=\"text-align: left;\">WE all are developing jave application for various area as it is one of the secure and non-hackle platform. So it\u2019s consider is most secured programming platform to choose. Here One of our servers went heavily loaded and we did not find any specific reasons to happen this. At the same time observed the CPU consumed heavily and RAM is barely used . So its seems like some memory leakage or code brake happening at web server end as we did not see any load conjunction on web server end.<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">So we need to dig the issue by collecting the Garbage collection data to a file. Based on the information which I\u2019d given, There are 3 basic types data that we need to identify the a root cause of a Java application.<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\"><strong>1. Collecting the Heap dump<\/strong><br \/>\nThis is basically pull what all the data are present in the system Memory. So this would help us to identify which function\/code is currently loaded in memory.<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\"><strong> How do I take thread dump : Execute the below command<\/strong><\/p>\n<div class=\"codecolorer-container text vibrant\" dir=\"ltr\" style=\"overflow: auto; white-space: nowrap; border: 1px solid #9f9f9f; width: 435px; text-align: left;\">\n<div class=\"text codecolorer\" style=\"padding: 5px; font: normal 12px\/1.4em Monaco, Lucida Console, monospace; white-space: nowrap;\">\u00a0\/var\/jdk\/bin\/jmap \u00a0-histo $(pgrep java) \u00a0 &gt; ~\/heapdump_$(date +&#8221;%Y-%m-%d_%H%M&#8221;).log<\/div>\n<\/div>\n<p dir=\"ltr\" style=\"text-align: left;\">The above command will pull the headp dump data to a dated separated file for future reference.<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\"><strong> 2. Collecting Thread dump<\/strong><br \/>\nThis is basically used for identify the programming side libraries\/functions\/forms those are being used in that particular time. This will be very useful to identify the functionality fix or brakes. So we had instructed to keep this data strictly up on any application outage.<\/p>\n<ul dir=\"ltr\" style=\"text-align: left;\">\n<li>How to pull the Thread dump<\/li>\n<\/ul>\n<div class=\"codecolorer-container text vibrant\" dir=\"ltr\" style=\"overflow: auto; white-space: nowrap; border: 1px solid #9f9f9f; width: 435px; text-align: left;\">\n<div class=\"text codecolorer\" style=\"padding: 5px; font: normal 12px\/1.4em Monaco, Lucida Console, monospace; white-space: nowrap;\">\u00a0\/var\/jdk\/bin\/jstack \u00a0-l $(pgrep java) \u00a0&gt; ~\/thread_dump_$(date +&#8221;%Y-%m-%d_%H%M&#8221;).log<\/div>\n<\/div>\n<p dir=\"ltr\" style=\"text-align: left;\"><strong> Note :<\/strong> This command will pull the backup of all the java thread currently being executed in the memory and written it as a dated file. You also need to take these logs for a period of time to understand the history of the function loaded in memory. So I used to execute this commands 3 times in one minute interval.<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\"><strong>3. Verifying java application is heavily used using jstat.<\/strong><\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">There is a utility <strong>(jstat)<\/strong> which collect the statistics of Garbage collection data which including the <strong>gcutils<\/strong> (used to check the usage of heap areas, the number of GC performed, and the total accumulated time for GC operations).<\/p>\n<div class=\"codecolorer-container text vibrant\" dir=\"ltr\" style=\"overflow: auto; white-space: nowrap; border: 1px solid #9f9f9f; width: 435px; text-align: left;\">\n<div class=\"text codecolorer\" style=\"padding: 5px; font: normal 12px\/1.4em Monaco, Lucida Console, monospace; white-space: nowrap;\">[root@web232 ~]# \/var\/jdk\/bin\/jstat -gcutil $(pgrep java) 250 700<br \/>\nS0 \u00a0 \u00a0 S1 \u00a0 \u00a0 E \u00a0 \u00a0 \u00a0O \u00a0 \u00a0 \u00a0P \u00a0 \u00a0 YGC \u00a0 \u00a0 YGCT \u00a0 \u00a0FGC \u00a0 \u00a0FGCT \u00a0 \u00a0 GCT<br \/>\n0.00 \u00a076.33 100.00 100.00 \u00a038.71 \u00a0 \u00a0133 \u00a0 15.991 \u00a0 229 1465.177 1481.168<br \/>\n0.00 \u00a076.33 100.00 100.00 \u00a038.71 \u00a0 \u00a0133 \u00a0 15.991 \u00a0 229 1465.177 1481.168<br \/>\n0.00 \u00a094.96 100.00 100.00 \u00a038.71 \u00a0 \u00a0133 \u00a0 15.991 \u00a0 229 1466.212 1482.203<br \/>\n0.00 100.00 100.00 100.00 \u00a038.71 \u00a0 \u00a0133 \u00a0 15.991 \u00a0 230 1466.212 1482.203<br \/>\n0.00 100.00 100.00 100.00 \u00a038.71 \u00a0 \u00a0133 \u00a0 15.991 \u00a0 230 1466.212 1482.203<br \/>\n0.00 100.00 100.00 100.00 \u00a038.71 \u00a0 \u00a0133 \u00a0 15.991 \u00a0 230 1466.212 1482.203<br \/>\n0.00 100.00 100.00 100.00 \u00a038.71 \u00a0 \u00a0133 \u00a0 15.991 \u00a0 230 1466.212 1482.203<br \/>\n0.00 100.00 100.00 100.00 \u00a038.71 \u00a0 \u00a0133 \u00a0 15.991 \u00a0 230 1466.212 1482.203<\/div>\n<\/div>\n<p dir=\"ltr\" style=\"text-align: left;\">The above logs showing that <strong>O<\/strong>ld space and <strong>E<\/strong>den space was fully occupied by GC cycle. So any pending GC request will be keep in queue and web server remains running in hanging states appears even though it is working correctly. The only culprit is GC collection killing the web server and keep it forzhen. So restarting webserver will help to release the GC and hence platform bring it back quickly.<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">If you see Eden space <strong>(E)<\/strong> and Old area <strong>(O)<\/strong> are showing the value 100. you application was driven in poor performance and may not be working correctly. So the options are restart the web server or kill the jave process.<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\"><strong>How do I kill the java process. <\/strong><\/p>\n<div class=\"codecolorer-container text vibrant\" dir=\"ltr\" style=\"overflow: auto; white-space: nowrap; border: 1px solid #9f9f9f; width: 435px; text-align: left;\">\n<div class=\"text codecolorer\" style=\"padding: 5px; font: normal 12px\/1.4em Monaco, Lucida Console, monospace; white-space: nowrap;\">\/bin\/kill -9 $(pgrep java)\u200b<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>WE all are developing jave application for various area as it is one of the secure and non-hackle platform. So it\u2019s consider is most secured programming platform to choose. Here One of our servers went heavily loaded and we did not find any specific reasons to happen this. At the same time observed the CPU &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[34,36],"tags":[],"class_list":["post-3018","post","type-post","status-publish","format-standard","hentry","category-server","category-36"],"_links":{"self":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/3018","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/comments?post=3018"}],"version-history":[{"count":0,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/3018\/revisions"}],"wp:attachment":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/media?parent=3018"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/categories?post=3018"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/tags?post=3018"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}