[LINUX] Java resource acquisition-High load, long time, freeze support-

Introduction

It does not mention how to investigate the information to be obtained. When Java is heavily loaded, lengthened, or freezes as a personal memorandum I will summarize the information I want to get.

The beginning

If Java takes a long time or freezes, do you (or your team) investigate it yourself? I think I will ask another team to investigate, but

"○○ has taken a long time! Please investigate! No information!" "(I don't know how to get the information, I don't know what to get) I killed it for the time being."

Sometimes that is the case. This does not allow the person being asked to investigate. In some cases "I can't investigate because there is no information, waiting for reproduction" Will it be "Let's make another turn to get information" It will be. I want to avoid that, so get the information when it happens, or get it.

However, this is not the case when there is a high load. If left untreated, it may adversely affect the entire system, so it is not possible to obtain information immediately. In that case, it is necessary to give priority to measures such as giving up and killing high-load processes.

Identifying the process ID

You need to identify the process ID of your Java app to get the information.

[In case of high load] You can specify it with the ps command, but the top command is easier to understand visually. You can monitor the performance status with the top command. Execute the top command after logging in to the server with high load.

[In case of long time / freeze] You can identify the process ID with the ps command. If the Java application is started in batch, from the command statement (script statement) You can identify the process ID. ps -ef | grep "Command statement" Since the process ID of the command statement can be obtained with the above command, the command statement is Gets the process ID of the process that is the parent process ID, and that process ID is Get the process that is the parent process ID, and repeat ... to get the process ID of the Java application. Can be identified. (There may be a smarter way ...)

Get the information you want to get

It is described as a little excessive. It is possible to output to a file by redirecting.

[Acquisition of disk information] df -k

[Getting a heap dump of only living objects]

live ${PID}



 [Get all heap dumps]

#### **`format=b,file=${OUT_PATH}/jmap_heap-dump.dat ${PID}`**
```jmap -dump


 [Getting a thread dump]
```jstack -l ${pid}```

 [Acquisition of performance status]
```top -bc -n 1```

 [Acquisition of process information]
```ps -ef |grep ${pid}```

 [Acquisition of GC status]
```jstat -gcutil ${pid} 10000 5```

 [Acquisition of network connection status]
```netstat```

 [Obtaining the port used by the process]
```lsof```

 [Acquisition of CPU information]
```cat /proc/cpuinfo```

 [Acquisition of memory information]
```cat /proc/meminfo```


## at the end
 I mentioned it briefly at the beginning, but what I wanted to convey in this article is more than how to acquire resources.
 It means that you should stop throwing the whole thing by telling only the event that caused the problem.
 When requesting a survey, attach as much content as you can to the survey.
 We recommend that you ask.


Recommended Posts

Java resource acquisition-High load, long time, freeze support-