我在我的生物环境中发现了一个问题。
我们在一个mq集群中有6个队列,我们有200个线程的线程池(实际上它将更多,因为它将在独立的线程池中安排一些特殊任务)来处理来自上游的请求,当处理请求时,我将向rabbitmq经纪人发布消息。
所以我有200个线程将消息发布到这6个队列。
对于每个队列,我将创建一个AMQP连接,并且对于每个线程,我有一个Channel的线程局,因此每个线程可以拥有自己的通道而不同步,因为通道不是线程安全的。
所以,实际上,我将打开1200个频道。请求qps大约是4000 / s,在某个特殊时间会有点大。
但是我发现200个线程都已耗尽,而且大多数都处于阻塞状态,如:
DubboServerHandler-10.12.26.124:9000-thread-200 - priority:10 - threadId:0x00007f6708030800 - nativeId:0x680d - state:BLOCKED
stackTrace:
java.lang.Thread.State: BLOCKED (on object monitor)
at com.rabbitmq.client.impl.SocketFrameHandler.writeFrame(SocketFrameHandler.java:170)
- waiting to lock <0x0000000738ad0190> (a java.io.DataOutputStream)
at com.rabbitmq.client.impl.AMQConnection.writeFrame(AMQConnection.java:542)
at com.rabbitmq.client.impl.AMQCommand.transmit(AMQCommand.java:104)
- locked <0x000000074e085338> (a com.rabbitmq.client.impl.CommandAssembler)
at com.rabbitmq.client.impl.AMQChannel.quiescingTransmit(AMQChannel.java:337)
- locked <0x000000074656eeb0> (a java.lang.Object)
at com.rabbitmq.client.impl.AMQChannel.transmit(AMQChannel.java:313)
- locked <0x000000074656eeb0> (a java.lang.Object)
at com.rabbitmq.client.impl.ChannelN.basicPublish(ChannelN.java:686)
at com.rabbitmq.client.impl.ChannelN.basicPublish(ChannelN.java:668)
at com.rabbitmq.client.impl.ChannelN.basicPublish(ChannelN.java:658)
at com.rabbitmq.client.impl.recovery.AutorecoveringChannel.basicPublish(AutorecoveringChannel.java:192)
这是我的jstack报告:http://fastthread.io/my-thread-report.jsp?p=c2hhcmVkLzIwMTgvMDIvMTEvLS0yNjE3OS50eHQtLTMtNTMtMzg=
我的问题是:
1.Why I have different channels to publish but they are all trying acquire the same lock
2.What will be the cause for this since this only happens tens of times in a day
3. Do I use a poor implementations for this? How can I improve it.
答案 0 :(得分:0)