rabbitMQ流控介绍以及测试验证

阿凡达2018-08-21 09:31

rabbitMQ流控介绍

rabbitMQ的流控可以分为两种:

  • 一种是单个链接上的流控:Per-Connection Flow Control
  • 一种是全局流控:
    • Memory-Based Flow Control
    • Disk-Based Flow Control

流控测试结果

per-connection flow

触发单个链接的流控可能是因为connection、channel、queue的某一个过程处于flow状态,这些状态都可以从监控平台上监控到。当单个队列达到最大流速时,或者多个队列达到总流速时,都会触发流控。

rabbitmq相关文章介绍

触发单个链接的流控,写消息的速率会降低,但是总体还是会有消息写入到消息队列中,所以说单个链接的流控不是阻塞状态的。

Memory-Based/Disk-Based Flow Control

内存和磁盘引起的全局流控,会导致线程一直处于网络写状态,线程被阻塞,且其他线程会处于Blocked状态。

线程状态信息如下:

"Thread-1" prio=6 tid=0x000000000c651800 nid=0xfb8 waiting for monitor entry [0x000000000d2be000]
   java.lang.Thread.State: BLOCKED (on object monitor)
    at java.io.BufferedOutputStream.write(Unknown Source)
    - waiting to lock <0x0000000781641638> (a java.io.BufferedOutputStream)
    at java.io.DataOutputStream.write(Unknown Source)
    - locked <0x0000000781641618> (a java.io.DataOutputStream)
    at java.io.ByteArrayOutputStream.writeTo(Unknown Source)
    - locked <0x00000007d6322228> (a java.io.ByteArrayOutputStream)
    at com.rabbitmq.client.impl.Frame.writeTo(Frame.java:193)
    at com.rabbitmq.client.impl.SocketFrameHandler.writeFrame(SocketFrameHandler.java:145)
    - locked <0x0000000781641618> (a java.io.DataOutputStream)
    at com.rabbitmq.client.impl.AMQConnection.writeFrame(AMQConnection.java:506)
    at com.rabbitmq.client.impl.AMQCommand.transmit(AMQCommand.java:106)
    - locked <0x00000007d6322070> (a com.rabbitmq.client.impl.CommandAssembler)
    at com.rabbitmq.client.impl.AMQChannel.quiescingTransmit(AMQChannel.java:321)
    - locked <0x000000078163ff10> (a java.lang.Object)
    at com.rabbitmq.client.impl.AMQChannel.transmit(AMQChannel.java:297)
    - locked <0x000000078163ff10> (a java.lang.Object)
    at com.rabbitmq.client.impl.ChannelN.basicPublish(ChannelN.java:648)
    at com.rabbitmq.client.impl.ChannelN.basicPublish(ChannelN.java:631)
    at com.rabbitmq.client.impl.ChannelN.basicPublish(ChannelN.java:622)
    at com.rabbitmq.client.impl.recovery.AutorecoveringChannel.basicPublish(AutorecoveringChannel.java:160)
    at com.netease.nim.device.rabbitmq.Publisher.publishRaw(Publisher.java:51)
    at com.netease.qaperf.mq.RmqProducerTestMain$2.run(RmqProducerTestMain.java:124)
    at java.lang.Thread.run(Unknown Source)

   Locked ownable synchronizers:
    - None

"Thread-0" prio=6 tid=0x000000000c53f800 nid=0x1cc4 runnable [0x000000000cf5e000]
   java.lang.Thread.State: RUNNABLE
    at java.net.SocketOutputStream.socketWrite0(Native Method)
    at java.net.SocketOutputStream.socketWrite(Unknown Source)
    at java.net.SocketOutputStream.write(Unknown Source)
    at java.io.BufferedOutputStream.flushBuffer(Unknown Source)
    at java.io.BufferedOutputStream.flush(Unknown Source)
    - locked <0x0000000781641638> (a java.io.BufferedOutputStream)
    at java.io.DataOutputStream.flush(Unknown Source)
    at com.rabbitmq.client.impl.SocketFrameHandler.flush(SocketFrameHandler.java:150)
    at com.rabbitmq.client.impl.AMQConnection.flush(AMQConnection.java:514)
    at com.rabbitmq.client.impl.AMQCommand.transmit(AMQCommand.java:125)
    at com.rabbitmq.client.impl.AMQChannel.quiescingTransmit(AMQChannel.java:321)
    - locked <0x0000000781640fc0> (a java.lang.Object)
    at com.rabbitmq.client.impl.AMQChannel.transmit(AMQChannel.java:297)
    - locked <0x0000000781640fc0> (a java.lang.Object)
    at com.rabbitmq.client.impl.ChannelN.basicPublish(ChannelN.java:648)
    at com.rabbitmq.client.impl.ChannelN.basicPublish(ChannelN.java:631)
    at com.rabbitmq.client.impl.ChannelN.basicPublish(ChannelN.java:622)
    at com.rabbitmq.client.impl.recovery.AutorecoveringChannel.basicPublish(AutorecoveringChannel.java:160)
    at com.netease.nim.device.rabbitmq.Publisher.publishRaw(Publisher.java:51)
    at com.netease.qaperf.mq.RmqProducerTestMain$2.run(RmqProducerTestMain.java:124)
    at java.lang.Thread.run(Unknown Source)



网易云新用户大礼包:https://www.163yun.com/gift

本文来自网易实践者社区,经作者侯本文授权发布。