ezhishui
ezhishui
2019-04-19 09:59

tomcat jvm 大量线程waiting on condition,如何解决?

  • java
  • tomcat

大佬们好,做性能压测遇到及其奇怪的问题,机器load极高,甚至飙到100+,逻辑核数只有16核
图片说明

jstack dump的线程有一半的线程都在waiting on condition,而且都是一些tomcat的线程池之类的问题线程栈如下:

图片说明
53%的线程都是如下堆栈

"catalina-exec-7" daemon prio=10 tid=0x00007f52fc016800 nid=0x1430 waiting on condition [0x00007f537abe7000]
   java.lang.Thread.State: WAITING (parking)
    at sun.misc.Unsafe.park(Native Method)
    - parking to wait for  <0x000000073168d480> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
    at java.util.concurrent.locks.LockSupport.park(LockSupport.java:186)
    at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2043)
    at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:442)
    at org.apache.tomcat.util.threads.TaskQueue.take(TaskQueue.java:104)
    at org.apache.tomcat.util.threads.TaskQueue.take(TaskQueue.java:32)
    at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1068)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Thread.java:745)

   Locked ownable synchronizers:
    - None

附上已确定的可以过滤的影响因素,其中cpu利用率81%,fullgc只有俩次,也不是fullgc问题引起的,parNew gc每次耗时20-40ms之间,也是合理的。内存也足够用
图片说明

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

2条回答