簡體   English   中英

activemq jdbc性能/延遲

[英]activemq jdbc performance / delays

我正在用jdbc store測試activemq,雖然我知道這不是最有效的方法,但我看到了很奇怪的延遲。

該代碼基本上將3k消息填充到隊列中,然后單個使用者將所有消息消耗掉。 消息是持久的,確認模式為AUTO_ACKNOWLEDGE。 我還禁用了alwaysSessionAsync和dispatchAsync。

問題是消費速度變化很大。 這是消耗100條消息所需的時間(全部消耗30倍):

2014-07-16 01:08:50,171  'consumer': 45.1 ms
2014-07-16 01:08:50,207  'consumer': 35.5 ms
2014-07-16 01:08:50,290  'consumer': 83.4 ms
2014-07-16 01:08:50,412  'consumer': 122 ms
2014-07-16 01:08:50,476  'consumer': 63.1 ms
2014-07-16 01:08:50,552  'consumer': 75.6 ms
2014-07-16 01:08:50,606  'consumer': 54.5 ms
2014-07-16 01:08:50,655  'consumer': 48.7 ms
2014-07-16 01:08:50,709  'consumer': 53.2 ms
2014-07-16 01:08:50,765  'consumer': 56.2 ms
2014-07-16 01:08:50,813  'consumer': 48.2 ms
2014-07-16 01:08:50,922  'consumer': 109 ms
2014-07-16 01:08:51,188  'consumer': 266 ms
2014-07-16 01:08:51,446  'consumer': 257 ms
2014-07-16 01:08:51,724  'consumer': 278 ms
2014-07-16 01:08:51,975  'consumer': 252 ms
2014-07-16 01:08:52,224  'consumer': 249 ms
2014-07-16 01:08:52,496  'consumer': 271 ms
2014-07-16 01:08:52,743  'consumer': 247 ms
2014-07-16 01:08:52,998  'consumer': 255 ms
2014-07-16 01:08:53,255  'consumer': 257 ms
2014-07-16 01:08:53,486  'consumer': 231 ms
2014-07-16 01:08:53,710  'consumer': 224 ms
2014-07-16 01:08:53,947  'consumer': 236 ms
2014-07-16 01:08:54,189  'consumer': 242 ms
2014-07-16 01:08:54,389  'consumer': 200 ms
2014-07-16 01:08:54,598  'consumer': 209 ms
2014-07-16 01:08:54,790  'consumer': 192 ms
2014-07-16 01:08:54,985  'consumer': 195 ms
2014-07-16 01:08:55,203  'consumer': 217 ms

因此,我啟用了TRACE級別的登錄功能,以發現是否有任何有趣的東西,並且確實存在差距:

2014-07-16 00:34:14,117 ActiveMQ BrokerService[broker_jdbc] Task-1 DEBUG || org.apache.activemq.broker.region.Queue - QUEUE2 toPageIn: 200, Inflight: 999, pagedInMessages.size 1214, pagedInPendingDispatch.size 214, enqueueCount: 3000, dequeueCount: 386, memUsage:1459248
2014-07-16 00:34:14,117 ActiveMQ BrokerService[broker_jdbc] Task-1 TRACE || org.apache.activemq.broker.region.Queue - Subscription full QueueSubscription: consumer=ID:LAPTOP-50558-1405488840024-5:1:1:1, destinations=1, dispatched=1000, delivered=0, pending=0
2014-07-16 00:34:14,117 ActiveMQ BrokerService[broker_jdbc] Task-1 TRACE || org.apache.activemq.thread.PooledTaskRunner - Running task iteration 572 - queue://QUEUE2, subscriptions=1, memory=1%, size=5771, in flight groups=null
2014-07-16 00:34:14,117 ActiveMQ BrokerService[broker_jdbc] Task-1 DEBUG || org.apache.activemq.broker.region.Queue - QUEUE2 toPageIn: 200, Inflight: 999, pagedInMessages.size 1214, pagedInPendingDispatch.size 214, enqueueCount: 3000, dequeueCount: 386, memUsage:1459248
2014-07-16 00:34:14,117 ActiveMQ BrokerService[broker_jdbc] Task-1 TRACE || org.apache.activemq.broker.region.Queue - Subscription full QueueSubscription: consumer=ID:LAPTOP-50558-1405488840024-5:1:1:1, destinations=1, dispatched=1000, delivered=0, pending=0
2014-07-16 00:34:14,117 ActiveMQ BrokerService[broker_jdbc] Task-1 TRACE || org.apache.activemq.thread.PooledTaskRunner - Running task iteration 573 - queue://QUEUE2, subscriptions=1, memory=1%, size=5771, in flight groups=null
2014-07-16 00:34:14,117 ActiveMQ BrokerService[broker_jdbc] Task-1 DEBUG || org.apache.activemq.broker.region.Queue - QUEUE2 toPageIn: 200, Inflight: 999, pagedInMessages.size 1214, pagedInPendingDispatch.size 214, enqueueCount: 3000, dequeueCount: 386, memUsage:1459248
2014-07-16 00:34:14,117 ActiveMQ BrokerService[broker_jdbc] Task-1 TRACE || org.apache.activemq.broker.region.Queue - Subscription full QueueSubscription: consumer=ID:LAPTOP-50558-1405488840024-5:1:1:1, destinations=1, dispatched=1000, delivered=0, pending=0
2014-07-16 00:34:14,117 ActiveMQ Transport: tcp:///127.0.0.1:50562@50559 TRACE || org.apache.activemq.broker.region.PrefetchSubscription - ack: MessageAck {commandId = 392, responseRequired = false, ackType = 2, consumerId = ID:LAPTOP-50558-1405488840024-5:1:1:1, firstMessageId = ID:LAPTOP-50488-1405487850038-3:1:1:1:2017, lastMessageId = ID:LAPTOP-50488-1405487850038-3:1:1:1:2017, destination = queue://QUEUE2, transactionId = null, messageCount = 1, poisonCause = null}
2014-07-16 00:34:14,397 ActiveMQ BrokerService[broker_jdbc] Task-1 TRACE || org.apache.activemq.thread.PooledTaskRunner - Running task iteration 574 - queue://QUEUE2, subscriptions=1, memory=1%, size=5771, in flight groups=null
2014-07-16 00:34:14,397 ActiveMQ BrokerService[broker_jdbc] Task-1 DEBUG || org.apache.activemq.broker.region.Queue - QUEUE2 toPageIn: 200, Inflight: 998, pagedInMessages.size 1213, pagedInPendingDispatch.size 214, enqueueCount: 3000, dequeueCount: 387, memUsage:1458216
2014-07-16 00:34:14,397 ActiveMQ Transport: tcp:///127.0.0.1:50562@50559 TRACE || org.apache.activemq.broker.region.Queue - ack of ID:LAPTOP-50488-1405487850038-3:1:1:1:2017 with MessageAck {commandId = 392, responseRequired = false, ackType = 2, consumerId = ID:LAPTOP-50558-1405488840024-5:1:1:1, firstMessageId = ID:LAPTOP-50488-1405487850038-3:1:1:1:2017, lastMessageId = ID:LAPTOP-50488-1405487850038-3:1:1:1:2017, destination = queue://QUEUE2, transactionId = null, messageCount = 1, poisonCause = null}
2014-07-16 00:34:14,397 ActiveMQ BrokerService[broker_jdbc] Task-1 TRACE || org.apache.activemq.broker.region.PrefetchSubscription - ID:LAPTOP-50558-1405488840024-5:1:1:1 dispatched: ID:LAPTOP-50534-1405488592270-3:1:1:1:16 - queue://QUEUE2, dispatched: 1387, inflight: 999
2014-07-16 00:34:14,397 ActiveMQ BrokerService[broker_jdbc] Task-1 TRACE || org.apache.activemq.broker.region.Queue - assigned ID:LAPTOP-50534-1405488592270-3:1:1:1:16 to consumer ID:LAPTOP-50558-1405488840024-5:1:1:1
2014-07-16 00:34:14,397 ActiveMQ Transport: tcp://laptop/127.0.0.1:50559@50562 DEBUG || jmstest.JmsTest2 - consumer recv: ActiveMQTextMessage {commandId = 20, responseRequired = true, messageId = ID:LAPTOP-50534-1405488592270-3:1:1:1:16, originalDestination = null, originalTransactionId = null, producerId = ID:LAPTOP-50534-1405488592270-3:1:1:1, destination = queue://QUEUE2, transactionId = null, expiration = 0, timestamp = 1405488593001, arrival = 0, brokerInTime = 1405488593001, brokerOutTime = 1405488854397, correlationId = null, replyTo = null, persistent = true, type = null, priority = 4, groupID = null, groupSequence = 0, targetConsumerId = null, compressed = false, userID = null, content = org.apache.activemq.util.ByteSequence@1bca52f3, marshalledProperties = null, dataStructure = null, redeliveryCounter = 0, size = 0, properties = null, readOnlyProperties = true, readOnlyBody = true, droppable = false, jmsXGroupFirstForConsumer = false, text = text}
2014-07-16 00:34:14,397 ActiveMQ BrokerService[broker_jdbc] Task-1 TRACE || org.apache.activemq.broker.region.PrefetchSubscription - ID:LAPTOP-50558-1405488840024-5:1:1:1 dispatched: ID:LAPTOP-50534-1405488592270-3:1:1:1:17 - queue://QUEUE2, dispatched: 1388, inflight: 1000

注意中間有250ms +的延遲。

問題是-為什么會有這樣的延誤,以及如何消除它們? 另外-為什么時間一開始這么短(低於100毫秒),然后又增加到250毫秒? (更改預取大小會在性能降低時移動點)

我還注意到,將確認模式更改為CLIENT_ACKNOWLEDGE而不確認消息將使消費者超快(20ms / 100),但會在20秒鍾以上將其阻塞數次。

有時我也遇到過類似的問題。 經過調查,我發現我們可以調整Memory LimitPrefecth Limit參數以提高此類情況的性能。

默認情況下,activemq.xml文件中的memoryLimit設置為1MB。 此參數指示activemq可以在內存中保留的數據量(如果達到此限制,activemq需要進行IO調用以從持久性存儲中讀取數據,這會影響性能)。

我建議您增加此值,看看它是否可以帶來任何性能提升。

預取限制是可以調整以獲得性能增益的其他參數。 此參數的值根據您為activemq擁有的隊列配置而有所不同。

另一種選擇是使用FileBasedCursor

請參考此鏈接並檢查是否有幫助。 如果使用者未確認消息,ActiveMQ將停止向隊列使用者發送消息

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM