[英]Why can't I get performance boost while changing persistent activemq messages to non-persistent?
I'm trying to get a higher speed for sending messages via ActiveMQ broker. 我正在尝试提高通过ActiveMQ代理发送消息的速度。
The problem is, that I don't get a great perfomence boost. 问题是,我的性能提升不高。 It takes about 2 minutes 40 seconds to send 10000 persistent messages from queue №1 to queue №2 via my service.
通过我的服务,从№1队列到№2队列发送10000条持久消息大约需要2分40秒。 And it takes about 2 minutes 20 seconds to send 10000 non-persistent messages.
发送10000条非持久性消息大约需要2分20秒。 I'm expecting to get at lest x10 speed perfomence for non-persistent mode.
我期望在非持久模式下获得至少x10的速度性能。 Actually I can get it setting transacted property to "false":
实际上,我可以将交易属性设置为“ false”来获得它:
<property name="transacted" value="false"/>
But this is not an option, I need transacted mode for messages that are perstitent. 但这不是一个选择,我需要持久性消息的事务处理模式。
I have configured ActiveMQ like this: 我已经这样配置ActiveMQ:
<bean class="org.apache.activemq.ActiveMQConnectionFactory" id="jmsConnectionFactory">
<property name="brokerURL" value="${AMQ.URL}"/>
<property name="userName" value="${AMQ.USER}"/>
<property name="password" value="${AMQ.PASSWORD}"/>
</bean>
<bean class="org.apache.activemq.pool.PooledConnectionFactory"
destroy-method="stop" id="jmsConnectionPool" init-method="start">
<property name="maxConnections" value="10"/>
<property name="connectionFactory" ref="jmsConnectionFactory"/>
</bean>
<bean class="org.apache.camel.component.jms.JmsConfiguration" id="jmsConfig">
<property name="connectionFactory" ref="jmsConnectionPool"/>
<property name="concurrentConsumers" value="10"/>
<property name="preserveMessageQos" value="true"/>
<property name="transacted" value="true"/>
<property name="cacheLevelName" value="CACHE_CONSUMER"/>
</bean>
<bean class="org.apache.activemq.camel.component.ActiveMQComponent" id="activemq">
<property name="configuration" ref="jmsConfig"/>
</bean>
Camel test route: 骆驼测试路线:
<route id="SRV.TEST">
<description>Test route</description>
<from uri="{{mqName}}:queue:{{test.in}}"/>
<to uri="{{mqName}}:queue:{{test.out}}"/>
</route>
Can anybody help, what am I doing wrong? 有人可以帮忙,我在做什么错?
As Justin said, transactionality and persistence are independent aspects in JMS, though transactions on non-persistent messages are very questionable - if you want the guarantees of transactions you need message persistence for the durability part of ACID. 正如Justin所说,事务性和持久性是JMS中的独立方面,尽管非持久消息上的事务非常可疑-如果要保证事务的安全性,就需要ACID持久性部分中的消息持久性。
Much of the performance of persistent messages depends on your broker configuration especially the message store backend. 持久消息的大部分性能取决于您的代理配置,尤其是消息存储后端。 So if you really want transactions (which somewhat implies you want persistence) you should try to configure a fast message store eg using kahadb on a write-fast storage like a flash-buffered SSD or SAN.
因此,如果您确实想要事务(这在某种程度上意味着您需要持久性),则应尝试配置快速消息存储,例如在快写存储(例如闪存缓冲SSD或SAN)上使用kahadb。
Another option could be using the modernized variant of ActiveMQ, Artemis ( https://activemq.apache.org/components/artemis/ ) which sports a faster append-only storage. 另一种选择是使用ActiveMQ的现代化变体Artemis( https://activemq.apache.org/components/artemis/ ),它具有更快的仅附加存储。
If you proceed without persistence, which might be fine for your use case, you could think about dropping transactions as well (not durable anyways) but note that persistence is set on a per-message basis when writing that exact message to a queue. 如果您在没有持久性的情况下继续进行操作(这可能适合您的用例),那么您也可以考虑删除事务(无论如何都不持久),但请注意,在将确切的消息写入队列时,持久性是基于每个消息设置的。
In Camel this can be done using the deliveryPersistent option on the URI like 在Camel中,可以使用URI上的deliveryPersistent选项来完成,例如
<to uri="{{mqName}}:queue:{{test.out}}?deliveryPersistent=false"/>
Also in your example you'd really need to make sure that all incoming messages were written to input queue {{test.in}} already non-persistent! 另外,在你的榜样,你真的很需要确保所有传入的消息被写入输入队列{{test.in}} 已非持久!
The transient non-persistent messages also need to fit into your broker's RAM or it will start paging them out to disk anyways. 临时非持久消息还需要放入代理的RAM中,否则它将开始将它们分页到磁盘。 So again your broker configuration is relevant (network too, of course).
因此,您的代理配置同样也很重要(当然,网络也是如此)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.