天天看點

Jprofiler監控伺服器的cpu

現象:壓測過程中,發現應用伺服器的cpu使用率比較高>80%,我們就可以判斷伺服器的cpu使用率太高了。

一般cpu太高有兩種情況,

1.接口的性能非常好,比如響應時間<10ms,tps很高,此時的cpu使用率高是正常的,不需要優化;

2.接口性能不好,比如響應時間>200ms,tps很低,此時需要考慮優化。

cpu消耗過高的原因:

1.使用了複雜的算法,比如加密,解密;

2,檔案的壓縮和解壓,序列化等操作;

3.代碼bug,比如死循環。

序列化

代碼中的對象->json字元串的轉換(大多是這個)

對象->檔案的轉換

我們通常使用jprofiler監控工具監控cpu。

jprofiler

1、安裝

Linux下指令:rpm -ivh jprofiler_linux_11_0.rpm

預設安裝到/opt/jprofiler11

2、服務端配置

tomcat中配置監控參數,在catalina.sh檔案中

在JAVA_OPTS=後面,雙引号中添加-agentpath:/opt/jprofiler11/bin/linux-x64/libjprofilerti.so=port=8849,nowait

配置完成後,重新開機tomcat才能生效

3、用戶端配置

按照提示一步步配置即可

4、用戶端連結服務端:

Jprofiler監控伺服器的cpu
Jprofiler監控伺服器的cpu
Jprofiler監控伺服器的cpu
Jprofiler監控伺服器的cpu
Jprofiler監控伺服器的cpu

連結伺服器:

Jprofiler監控伺服器的cpu

伺服器jprofiler的路徑:

Jprofiler監控伺服器的cpu

jprofiler的端口:

Jprofiler監控伺服器的cpu
Jprofiler監控伺服器的cpu

修改伺服器配置并且重新開機tomcat:

Jprofiler監控伺服器的cpu

伺服器和win都安裝後監控cpu:

Jprofiler監控伺服器的cpu

繼續閱讀