简体   繁体   中英

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.

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. And it takes about 2 minutes 20 seconds to send 10000 non-persistent messages. I'm expecting to get at lest x10 speed perfomence for non-persistent mode. Actually I can get it setting transacted property to "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:

<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.

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.

Another option could be using the modernized variant of ActiveMQ, Artemis ( https://activemq.apache.org/components/artemis/ ) which sports a faster append-only storage.

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

<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!

The transient non-persistent messages also need to fit into your broker's RAM or it will start paging them out to disk anyways. So again your broker configuration is relevant (network too, of course).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM