Vert.x Service with threadpool executor service,CPU使用率高

时间:2016-03-03 06:37:04

标签: java multithreading rabbitmq threadpoolexecutor vert.x

我在使用centOS的24核CPU上使用vet.x 8实例运行java应用程序,使用threadpool插入rabbitMQ,有时我的CPU使用率达到100%且应用程序停留了一段时间 同时在同一台服务器上,我正在运行rabbitMQ用户接收信标,我也在使用线程池服务

2016-03-03 11:17:06
Full thread dump Java HotSpot(TM) 64-Bit Server VM (24.71-b01 mixed mode):

"Attach Listener" daemon prio=10 tid=0x00007ff088001000 nid=0x3b53 waiting on condition [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

"pool-1-thread-2" prio=10 tid=0x00007ff050104000 nid=0x3846 waiting on condition [0x00007ff110d92000]
   java.lang.Thread.State: TIMED_WAITING (parking)
        at sun.misc.Unsafe.park(Native Method)
        - parking to wait for  <0x000000072eca42c8> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
        at java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:226)
        at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2082)
        at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:1090)
        at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:807)
        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 java.lang.Thread.run(Thread.java:745)

"pool-1-thread-1" prio=10 tid=0x00007ff05003d800 nid=0x3845 runnable [0x00007ff110e93000]
   java.lang.Thread.State: RUNNABLE
        at java.net.SocketInputStream.socketRead0(Native Method)
        at java.net.SocketInputStream.read(SocketInputStream.java:152)
        at java.net.SocketInputStream.read(SocketInputStream.java:122)
        at java.io.BufferedInputStream.fill(BufferedInputStream.java:235)
        at java.io.BufferedInputStream.read(BufferedInputStream.java:254)
        - locked <0x000000072ec17850> (a java.io.BufferedInputStream)
        at java.io.DataInputStream.readUnsignedByte(DataInputStream.java:288)
        at com.rabbitmq.client.impl.Frame.readFrom(Frame.java:95)
        at com.rabbitmq.client.impl.SocketFrameHandler.readFrame(SocketFrameHandler.java:139)
        - locked <0x000000072ec17830> (a java.io.DataInputStream)
 at com.rabbitmq.client.impl.AMQConnection$MainLoop.run(AMQConnection.java:534)
        at java.lang.Thread.run(Thread.java:745)

"threadDeathWatcher-2-1" daemon prio=10 tid=0x00007ff060265000 nid=0x3844 waiting on condition [0x00007ff111f95000]
   java.lang.Thread.State: TIMED_WAITING (sleeping)
        at java.lang.Thread.sleep(Native Method)
        at io.netty.util.ThreadDeathWatcher$Watcher.run(ThreadDeathWatcher.java:113)
        at java.lang.Thread.run(Thread.java:745)

"vert.x-eventloop-thread-0" daemon prio=10 tid=0x00007ff05c00f000 nid=0x3841 runnable [0x00007ff112096000]
   java.lang.Thread.State: RUNNABLE
        at sun.nio.ch.EPollArrayWrapper.epollWait(Native Method)
        at sun.nio.ch.EPollArrayWrapper.poll(EPollArrayWrapper.java:269)
        at sun.nio.ch.EPollSelectorImpl.doSelect(EPollSelectorImpl.java:79)
        at sun.nio.ch.SelectorImpl.lockAndDoSelect(SelectorImpl.java:87)
        - locked <0x0000000411810180> (a io.netty.channel.nio.SelectedSelectionKeySet)
        - locked <0x0000000411810170> (a java.util.Collections$UnmodifiableSet)
        - locked <0x0000000411810128> (a sun.nio.ch.EPollSelectorImpl)
 at sun.nio.ch.SelectorImpl.select(SelectorImpl.java:98)
        at io.netty.channel.nio.NioEventLoop.select(NioEventLoop.java:618)
        at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:306)
        at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:116)
        at java.lang.Thread.run(Thread.java:745)

"vert.x-eventloop-thread-8" daemon prio=10 tid=0x00007ff074019800 nid=0x383e runnable [0x00007ff112197000]
   java.lang.Thread.State: RUNNABLE
        at sun.nio.ch.EPollArrayWrapper.epollWait(Native Method)
        at sun.nio.ch.EPollArrayWrapper.poll(EPollArrayWrapper.java:269)
        at sun.nio.ch.EPollSelectorImpl.doSelect(EPollSelectorImpl.java:79)
        at sun.nio.ch.SelectorImpl.lockAndDoSelect(SelectorImpl.java:87)
        - locked <0x0000000411810330> (a io.netty.channel.nio.SelectedSelectionKeySet)
        - locked <0x0000000411810320> (a java.util.Collections$UnmodifiableSet)
        - locked <0x00000004118102d8> (a sun.nio.ch.EPollSelectorImpl)
        at sun.nio.ch.SelectorImpl.select(SelectorImpl.java:98)
        at io.netty.channel.nio.NioEventLoop.select(NioEventLoop.java:618)
        at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:306)
 at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:116)
        at java.lang.Thread.run(Thread.java:745)

"vert.x-eventloop-thread-7" daemon prio=10 tid=0x00007ff074017800 nid=0x383d runnable [0x00007ff112298000]
   java.lang.Thread.State: RUNNABLE
        at sun.nio.ch.EPollArrayWrapper.epollWait(Native Method)
        at sun.nio.ch.EPollArrayWrapper.poll(EPollArrayWrapper.java:269)
        at sun.nio.ch.EPollSelectorImpl.doSelect(EPollSelectorImpl.java:79)
        at sun.nio.ch.SelectorImpl.lockAndDoSelect(SelectorImpl.java:88)
        - locked <0x0000000411813190> (a io.netty.channel.nio.SelectedSelectionKeySet)
        - locked <0x0000000411813180> (a java.util.Collections$UnmodifiableSet)
        - locked <0x0000000411813138> (a sun.nio.ch.EPollSelectorImpl)
        at sun.nio.ch.SelectorImpl.select(SelectorImpl.java:98)
        at io.netty.channel.nio.NioEventLoop.select(NioEventLoop.java:618)
        at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:306)
        at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:116)
        at java.lang.Thread.run(Thread.java:745)
"vert.x-eventloop-thread-6" daemon prio=10 tid=0x00007ff074015000 nid=0x383c runnable [0x00007ff112399000]
   java.lang.Thread.State: RUNNABLE
        at sun.nio.ch.EPollArrayWrapper.epollWait(Native Method)
        at sun.nio.ch.EPollArrayWrapper.poll(EPollArrayWrapper.java:269)
        at sun.nio.ch.EPollSelectorImpl.doSelect(EPollSelectorImpl.java:79)
        at sun.nio.ch.SelectorImpl.lockAndDoSelect(SelectorImpl.java:87)
        - locked <0x0000000411813340> (a io.netty.channel.nio.SelectedSelectionKeySet)
        - locked <0x0000000411813330> (a java.util.Collections$UnmodifiableSet)
        - locked <0x00000004118132e8> (a sun.nio.ch.EPollSelectorImpl)
        at sun.nio.ch.SelectorImpl.select(SelectorImpl.java:98)
        at io.netty.channel.nio.NioEventLoop.select(NioEventLoop.java:618)
        at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:306)
        at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:116)
        at java.lang.Thread.run(Thread.java:745)

"vert.x-eventloop-thread-7" daemon prio=10 tid=0x00007ff074017800 nid=0x383d runnable [0x00007ff112298000]
   java.lang.Thread.State: RUNNABLE
        at sun.nio.ch.EPollArrayWrapper.epollWait(Native Method)
        at sun.nio.ch.EPollArrayWrapper.poll(EPollArrayWrapper.java:269)
        at sun.nio.ch.EPollSelectorImpl.doSelect(EPollSelectorImpl.java:79)
        at sun.nio.ch.SelectorImpl.lockAndDoSelect(SelectorImpl.java:88)
        - locked <0x0000000411813190> (a io.netty.channel.nio.SelectedSelectionKeySet)
        - locked <0x0000000411813180> (a java.util.Collections$UnmodifiableSet)
        - locked <0x0000000411813138> (a sun.nio.ch.EPollSelectorImpl)
        at sun.nio.ch.SelectorImpl.select(SelectorImpl.java:98)
        at io.netty.channel.nio.NioEventLoop.select(NioEventLoop.java:618)
        at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:306)
        at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:116)
        at java.lang.Thread.run(Thread.java:745)


 .
    .
    similar types of threads 
    .
    .
"vert.x-worker-thread-0" daemon prio=10 tid=0x00007ff14c6f8800 nid=0x3836 waiting on condition [0x00007ff11299f000]
   java.lang.Thread.State: WAITING (parking)
        at sun.misc.Unsafe.park(Native Method)
        - parking to wait for  <0x000000041181b260> (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 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 java.lang.Thread.run(Thread.java:745)
"Service Thread" daemon prio=10 tid=0x00007ff14c0bd800 nid=0x3832 runnable [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

"C2 CompilerThread1" daemon prio=10 tid=0x00007ff14c0bb800 nid=0x3831 waiting on condition [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

"C2 CompilerThread0" daemon prio=10 tid=0x00007ff14c0b8800 nid=0x3830 waiting on condition [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

"Signal Dispatcher" daemon prio=10 tid=0x00007ff14c0b6000 nid=0x382f runnable [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

    "Reference Handler" daemon prio=10 tid=0x00007ff14c08b000 nid=0x382d in Object.wait() [0x00007ff113ffe000]
       java.lang.Thread.State: WAITING (on object monitor)
            at java.lang.Object.wait(Native Method)
            - waiting on <0x0000000411821098> (a java.lang.ref.Reference$Lock)
            at java.lang.Object.wait(Object.java:503)
            at java.lang.ref.Reference$ReferenceHandler.run(Reference.java:133)
            - locked <0x0000000411821098> (a java.lang.ref.Reference$Lock)

    "main" prio=10 tid=0x00007ff14c009000 nid=0x3819 waiting on condition [0x00007ff153b03000]
       java.lang.Thread.State: WAITING (parking)
            at sun.misc.Unsafe.park(Native Method)
            - parking to wait for  <0x0000000411825030> (a java.util.concurrent.CountDownLatch$Sync)
            at java.util.concurrent.locks.LockSupport.park(LockSupport.java:186)
            at java.util.concurrent.locks.AbstractQueuedSynchronizer.parkAndCheckInterrupt(AbstractQueuedSynchronizer.java:834)
      at java.util.concurrent.CountDownLatch.await(CountDownLatch.java:236)
            at org.vertx.java.platform.impl.cli.Starter.block(Starter.java:382)
            at org.vertx.java.platform.impl.cli.Starter.runVerticle(Starter.java:376)
            at org.vertx.java.platform.impl.cli.Starter.<init>(Starter.java:88)
            at org.vertx.java.platform.impl.cli.Starter.main(Starter.java:55)

    "VM Thread" prio=10 tid=0x00007ff14c087000 nid=0x382c runnable

    "GC task thread#0 (ParallelGC)" prio=10 tid=0x00007ff14c01e800 nid=0x381a runnable

    "GC task thread#1 (ParallelGC)" prio=10 tid=0x00007ff14c020800 nid=0x381b runnable

    "GC task thread#2 (ParallelGC)" prio=10 tid=0x00007ff14c022800 nid=0x381c runnable

    "GC task thread#3 (ParallelGC)" prio=10 tid=0x00007ff14c024800 nid=0x381d runnable

    "GC task thread#4 (ParallelGC)" prio=10 tid=0x00007ff14c026000 nid=0x381e runnab

1 个答案:

答案 0 :(得分:1)

您似乎从事件循环中调用了您的rabbitmq客户端。它通常是被禁止的,因为你阻止了事件循环。您应该使用vertx.executeBlocking中的rabbitmq客户端来处理像rabbitmq这样的远程服务。您将使用工作池中的线程执行代码。从vert.x 3.3开始,您可以更密切地监视工作池。

我建议尝试使用rabbit.xq-client for Vert.x:http://vertx.io/docs/vertx-rabbitmq-client/java/,因为它会为你管理executeBlocking。