java进程cpu飘高排查

一个线上应用突然访问很慢,通过浏览器访问系统页面一直处于加载状态。登录服务器进行排查,排查过程如下:

查看服务器使用情况

使用命令来查看服务器的使用情况,发现有个进程号为java进程使用比较高,通过命令进一步确认飘高的进程就是所访问应用的进程。使用命令查看此java进程,结果如下:

根据命令结果可以发现,线程号为、等几个线程的占用比较严重。

使用命令查看线程信息

命令执行结果如下(内容较多,只截取了部分关键信息):

2018-02-2816:48:15

FullthreaddumpJavaHotSpot(TM)64-BitServerVM(24.45-b08mixedmode):

"pool-976522-thread-1"prio=10tid=0x00007f1cd8987800nid=0x59e0waitingoncondition[0x00007f1c134f3000]

java.lang.Thread.State:WAITING(parking)

atsun.misc.Unsafe.park(NativeMethod)

atch.qos.logback.core.OutputStreamAppender.subAppend(OutputStreamAppender.java:210)

atch.qos.logback.core.OutputStreamAppender.append(OutputStreamAppender.java:100)

atch.qos.logback.core.UnsynchronizedAppenderBase.doAppend(UnsynchronizedAppenderBase.java:84)

atch.qos.logback.core.spi.AppenderAttachableImpl.appendLoopOnAppenders(AppenderAttachableImpl.java:48)

atch.qos.logback.classic.Logger.appendLoopOnAppenders(Logger.java:270)

atch.qos.logback.classic.Logger.callAppenders(Logger.java:257)

atch.qos.logback.classic.Logger.buildLoggingEventAndAppend(Logger.java:421)

atjava.lang.Thread.run(Thread.java:744)

Lockedownablesynchronizers:

"GC Daemon"daemonprio=10tid=0x00007f1ce44f4000nid=0x4a9cinObject.wait() [0x00007f1cb115c000]

java.lang.Thread.State:TIMED_WAITING(onobjectmonitor)

atjava.lang.Object.wait(NativeMethod)

-waitingon(asun.misc.GC$LatencyLock)

atsun.misc.GC$Daemon.run(GC.java:117)

-locked(asun.misc.GC$LatencyLock)

Lockedownablesynchronizers:

-None

"Service Thread"daemonprio=10tid=0x00007f1ce4099000nid=0x4a99runnable[0x0000000000000000]

java.lang.Thread.State:RUNNABLE

Lockedownablesynchronizers:

-None

"C2 CompilerThread1"daemonprio=10tid=0x00007f1ce4097000nid=0x4a98waitingoncondition[0x0000000000000000]

java.lang.Thread.State:RUNNABLE

Lockedownablesynchronizers:

-None

"C2 CompilerThread0"daemonprio=10tid=0x00007f1ce4094000nid=0x4a97waitingoncondition[0x0000000000000000]

java.lang.Thread.State:RUNNABLE

Lockedownablesynchronizers:

-None

"Signal Dispatcher"daemonprio=10tid=0x00007f1ce4089800nid=0x4a96runnable[0x0000000000000000]

java.lang.Thread.State:RUNNABLE

Lockedownablesynchronizers:

-None

"Finalizer"daemonprio=10tid=0x00007f1ce4073000nid=0x4a95inObject.wait() [0x00007f1cd01d3000]

java.lang.Thread.State:WAITING(onobjectmonitor)

atjava.lang.Object.wait(NativeMethod)

Lockedownablesynchronizers:

-None

"Reference Handler"daemonprio=10tid=0x00007f1ce406f000nid=0x4a94inObject.wait() [0x00007f1cd02d4000]

java.lang.Thread.State:WAITING(onobjectmonitor)

atjava.lang.Object.wait(NativeMethod)

atjava.lang.Object.wait(Object.java:503)

Lockedownablesynchronizers:

-None

"main"prio=10tid=0x00007f1ce4009000nid=0x4a8crunnable[0x00007f1ce9b98000]

java.lang.Thread.State:RUNNABLE

atjava.net.PlainSocketImpl.socketAccept(NativeMethod)

atjava.net.AbstractPlainSocketImpl.accept(AbstractPlainSocketImpl.java:398)

atjava.net.ServerSocket.implAccept(ServerSocket.java:530)

atjava.net.ServerSocket.accept(ServerSocket.java:498)

atsun.reflect.NativeMethodAccessorImpl.invoke0(NativeMethod)

atsun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

atsun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

Lockedownablesynchronizers:

-None

"VM Thread"prio=10tid=0x00007f1ce406c800nid=0x4a93runnable

"GC task thread#0 (ParallelGC)"prio=10tid=0x00007f1ce401e800nid=0x4a8drunnable

"GC task thread#1 (ParallelGC)"prio=10tid=0x00007f1ce4020800nid=0x4a8erunnable

"GC task thread#2 (ParallelGC)"prio=10tid=0x00007f1ce4022000nid=0x4a8frunnable

"GC task thread#3 (ParallelGC)"prio=10tid=0x00007f1ce4024000nid=0x4a90runnable

"GC task thread#4 (ParallelGC)"prio=10tid=0x00007f1ce4026000nid=0x4a91runnable

"GC task thread#5 (ParallelGC)"prio=10tid=0x00007f1ce4028000nid=0x4a92runnable

"VM Periodic Task Thread"prio=10tid=0x00007f1ce40a4000nid=0x4a9awaitingoncondition

JNIglobalreferences:251

命令结果中的线程号转换为十六进制(),并在命令结果中查找的线程,结果如下:

从结果来看几个占用严重的线程都是在做,使用查看进程的情况,从结果看在频繁的做,而之所以触发是因为空间不足:

反过来在使用查看应用中间件参数配置,从结果可以看出应用中间件对设置比较小,修改应用中间件的启动脚本文件调大对的设置重启后问题解决:

  • 发表于:
  • 原文链接:http://kuaibao.qq.com/s/20180414G16I5G00?refer=cp_1026
  • 腾讯「云+社区」是腾讯内容开放平台帐号(企鹅号)传播渠道之一,根据《腾讯内容开放平台服务协议》转载发布内容。

扫码关注云+社区

领取腾讯云代金券