线上load高的问题排查步骤是:

  1. 先用top找到耗资源的进程
  2. ps+grep找到对应的java进程/线程
  3. jstack分析哪些线程阻塞了,阻塞在哪里
  4. jstat看看FullGC频率
  5. jmap看看有没有内存泄露
使用jstack查看的例子:
C:\Users\Iammeaz>jstack 4696
2016-01-08 10:26:06
Full thread dump Java HotSpot(TM) 64-Bit Server VM (11.3-b02 mixed mode):
 
"Low Memory Detector" daemon prio=6 tid=0x000000006a63f800 nid=0x1790 runnable [0x0000000000000000..0x0000000000000000]
   java.lang.Thread.State: RUNNABLE
 
"CompilerThread1" daemon prio=10 tid=0x000000006a63a400 nid=0x1780 waiting on condition [0x0000000000000000..0x000000006
   java.lang.Thread.State: RUNNABLE
 
"CompilerThread0" daemon prio=10 tid=0x000000006a62d000 nid=0x136c waiting on condition [0x0000000000000000..0x000000000
   java.lang.Thread.State: RUNNABLE
 
"JDWP Command Reader" daemon prio=6 tid=0x000000006a612c00 nid=0x13c0 runnable [0x0000000000000000..0x0000000000000000]
   java.lang.Thread.State: RUNNABLE
 
"JDWP Event Helper Thread" daemon prio=6 tid=0x000000006a612000 nid=0x1bf4 runnable [0x0000000000000000..0x0000000000000
   java.lang.Thread.State: RUNNABLE
 
"JDWP Transport Listener: dt_socket" daemon prio=6 tid=0x000000006a60b000 nid=0x1be0 runnable [0x0000000000000000..0x000
   java.lang.Thread.State: RUNNABLE
 
"Attach Listener" daemon prio=10 tid=0x000000006a5f7c00 nid=0x1340 waiting on condition [0x0000000000000000..0x000000000
   java.lang.Thread.State: RUNNABLE
 
"Signal Dispatcher" daemon prio=10 tid=0x000000006a5a5800 nid=0x11e0 runnable [0x0000000000000000..0x0000000000000000]
   java.lang.Thread.State: RUNNABLE
 
"Finalizer" daemon prio=8 tid=0x000000006a594000 nid=0x13c4 in Object.wait() [0x000000006a9ef000..0x000000006a9ef890]
   java.lang.Thread.State: WAITING (on object monitor)
        at java.lang.Object.wait(Native Method)
        - waiting on <0x000000004a071210> (a java.lang.ref.ReferenceQueue$Lock)
        at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:116)
        - locked <0x000000004a071210> (a java.lang.ref.ReferenceQueue$Lock)
        at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:132)
        at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:159)
 
"Reference Handler" daemon prio=10 tid=0x000000006a593400 nid=0x1598 in Object.wait() [0x000000006a8ef000..0x000000006a8
   java.lang.Thread.State: WAITING (on object monitor)
        at java.lang.Object.wait(Native Method)
        - waiting on <0x000000004a071078> (a java.lang.ref.Reference$Lock)
        at java.lang.Object.wait(Object.java:485)
        at java.lang.ref.Reference$ReferenceHandler.run(Reference.java:116)
        - locked <0x000000004a071078> (a java.lang.ref.Reference$Lock)
 
"main" prio=6 tid=0x000000000062c800 nid=0x1190 at breakpoint[0x00000000025bf000..0x00000000025bfc50]
   java.lang.Thread.State: RUNNABLE
        at com.damonzh.maxsubseqsum.Demo01.MaxSubseqSum1(Demo01.java:15)
        at com.damonzh.maxsubseqsum.Demo01.main(Demo01.java:7)
 
"VM Thread" prio=10 tid=0x0000000000525000 nid=0x14cc runnable
 
"GC task thread#0 (ParallelGC)" prio=6 tid=0x0000000000471400 nid=0x105c runnable
 
"GC task thread#1 (ParallelGC)" prio=6 tid=0x0000000000472800 nid=0xe94 runnable
 
"GC task thread#2 (ParallelGC)" prio=6 tid=0x0000000000474000 nid=0x180c runnable
 
"GC task thread#3 (ParallelGC)" prio=6 tid=0x0000000000475400 nid=0xe14 runnable
 
"VM Periodic Task Thread" prio=10 tid=0x000000000046d400 nid=0x494 waiting on condition
 
JNI global references: 1062
 
但这个还不是重点,那么问题来了(blue fly is the strongest):这些工具如何能获取远程Java进程的信息的?又是如何远程控制Java进程的运行的?

相信有不少人和我一样对这些工具的 实现原理 。

Java调试体系JPDA

Java虚拟机设计了专门的API接口供调试和监控虚拟机使用,被称为Java平台调试体系即Java Platform Debugger Architecture(JPDA)。

04-30 20:23