blob: 2b04f0a2009d55c6045c4e2b6ab61fbbc1823683 [file] [log] [blame]
<div class="wiki-content maincontent"><p>For a more complete overview see <a shape="rect" href="performance.html">Performance</a>.</p><p>There are trade-offs between performance and reliability. By default, ActiveMQ strikes a balance between the two, so there are some things you can change to increase throughput.</p><h2 id="PerformanceTuning-AsyncPublishing">Async Publishing</h2><p>First some background:</p><p>When an ActiveMQ message producer sends a non-persistent message, its dispatched asynchronously (fire and forget) - but for persistent messages, the publisher will block until it gets a notification that the message has been processed (saved to the store - queued to be dispatched to any active consumers etc) by the broker. messages are dispatched with delivery mode set to be persistent by default (which is required by the JMS spec). So if you are sending messages on a Topic, the publisher will block by default (even if there are no durable subscribers on the topic) until the broker has returned a notification.</p><p>So if you looking for good performance with topic messages, either set the delivery mode on the publisher to be non-persistent, or set the&#160;<strong><code>useAsyncSend</code></strong> property on the ActiveMQ ConnectionFactory to be <strong>true</strong>.</p><h2 id="PerformanceTuning-Pre-fetchSizesforConsumers">Pre-fetch Sizes for Consumers</h2><p>ActiveMQ will push as many messages to the consumer as fast as possible, where they will be queued for processing by an ActiveMQ Session. The maximum number of messages that ActiveMQ will push to a Consumer without the Consumer processing a message is set by the pre-fetch size. You can improve throughput by running ActiveMQ with larger pre-fetch sizes. Pre-fetch sizes are determined by the&#160;<strong><code>ActiveMQPrefetchPolicy</code></strong> bean, which is set on the ActiveMQ <strong><code>ConnectionFactory</code></strong>.</p><p>Default values:</p><div class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1" class="confluenceTh"><p>Consumer Type</p></th><th colspan="1" rowspan="1" class="confluenceTh"><p>Default Value</p></th></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>queue</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>1000</code></p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>queue browser</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>500</code></p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>topic</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>32767</code></p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>durable topic</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>1000</code></p></td></tr></tbody></table></div><h2 id="PerformanceTuning-OptimizedAcknowledge">Optimized Acknowledge</h2><p>When consuming messages in auto acknowledge mode (set when creating the consumers' session), ActiveMQ can acknowledge receipt of messages back to the broker in batches (to improve performance). The batch size is 65% of the prefetch limit for the Consumer. Also if message consumption is slow the batch will be sent every 300ms. You switch batch acknowledgment on by setting&#160;<strong><code>optimizeAcknowledge=true</code></strong> on the ActiveMQ&#160;<strong><code>ConnectionFactory</code></strong>.</p><h2 id="PerformanceTuning-StraightthroughSessionConsumption">Straight through Session Consumption</h2><p>By default, a Consumer's session will dispatch messages to the consumer in a separate thread. If you are using Consumers with auto acknowledge, you can increase throughput by passing messages straight through the Session to the Consumer by setting&#160;<strong><code>alwaysSessionAsync=false</code></strong> on the ActiveMQ&#160;<strong><code>ConnectionFactory</code></strong>.</p><h2 id="PerformanceTuning-FilebasedPersistence">File based Persistence</h2><p>We have a <a shape="rect" href="kaha-persistence.html">file based persistence store</a> that can be used to increase throughput for the persistent messages</p><p></p><h2 id="PerformanceTuning-Performanceguides">Performance guides</h2>
<p>If you're not convinced by performance reports then please do try running performance tests yourself. You might wanna check out our overview of <a shape="rect" href="performance.html">Performance</a> or try using out the <a shape="rect" href="activemq-performance-module-users-manual.html">ActiveMQ Performance Module Users Manual</a></p>
<p>The Commercial Providers on the <a shape="rect" href="support.html">Support</a> page may also be able to help diagnose performance issues, suggest changes, etc...</p></div>