`

JMS性能调优

阅读更多

FUSE Message Broker Performance Tuning Guide

<!-- Root decorator: this is a layer of abstraction that Confluence doesn't need. It will be removed eventually. -->
<!-- wiki content -->

The FUSE Message Broker is based on Apache ActiveMQ, which offers numerous options for perofmance optimization. There are various things which affect the performance of Apache ActiveMQ and there are many ways you can use to make it go faster depending on your exact requirements.

Choose the right Quality of Service

Using persistent messaging is quite a bit slower than non-persistent messaging. Many things are a tradeoff in IT between performance and quality of service.

With non-persistent messaging, things are reliable - unless the broker is killed in which case any messages in the broker are lost. Persistent messaging avoids this by ensuring by default that every message is written to disk before the MessageProducer.send() method returns.

Even if you need persistent messaging there are various things you can do to speed things up - such as do you really need to block the sender to wait until the message is physically on disk on the broker before being able to send another message? There now follows a number of options you can consider if you need the extra safety of persistent messaging.

Use Transactions

If you are using persistent messaging and you don't want to use Async Sends then you should use JMS transactions to batch up many operations inside a single transaction.

Even if you have to pay the performance cost of XA transactions - using batching (processing and sending many messages in a single transaction (JMS or XA) will boost performance considerably. This is because you share the synchrony cost (the waiting for things to be written and sync'd to disk) across many many messages.

Use asynchronous sending

If you enable Async Sends then you will reduce the blocking in senders which increases throughput.

Increase the prefetch size

ActiveMQ uses a prefetch size to determine how many messages are streamed to a JMS consumer. The higher this number then typically the higher the throughput of the consumers as it typically means under heavy message load then the consumer always has more messages available immediately in RAM for processing - rather than having to wait for messages to be read and parsed from a socket.

Use Session.DUPS_OK_ACKNOWLEDGE

For transient messages (non persistent) or where performance is more critical than QOS, use Session.DUPS_OK_ACKNOWLEDGE on message consumers. The message consumer can lazily acknowledge and batch receipt of messages to the broker - which will dramatically improve performance. However, if you use Session.DUPS_OK_ACKNOWLEDGE with durable topic or Queue consumers for persistent messages, duplicate messages can be received if a consumer terminates abnormally (is killed without closing).

Other flags

If you look at javadoc of ActiveMQConnection you will see a number of properties you can use.

For example if you enable the following flags

  • optimizedAcknowledge
  • optimizedMessageDispatch
  • useAsyncSend
  • asyncDispatch

You will generally make ActiveMQ go faster, acknowledge messages in batches and use asynchronous sending

You can set these properties on the Connection object using Java code or using the connection URI String such as for Async Sends

Reduce latency using embedded brokers

If you send a message from a producer to a consumer then there are 2 network hops; one to get to the broker then from the broker to the consumer.

You can reduce one network hop by deploying an embedded broker in either the producer or consumer. Then there is no network hop on one end which typically reduces latency.

Avoid TCP for embedded brokers

If you are using an embedded broker then using the VM Transport is much more efficient than using the TCP Transport as objects can be passed by reference rather than being marshalled onto/off of a socket..

For more details see How to Run a Broker

Avoid message copy

If you know you are not going to reuse the Message object after sending then disable copyMessageOnSend flag on the ActiveMQConnection (via Java code or the connection URI)

Avoid unnecessary object serialization

If you are using the VM Transport with an embedded broker and using ObjectMessage intances then you can optimise the use of serialization (assuming that the producer and consumer are using the same classpath to avoid classloader issues).

To do this enable the objectMessageSerializeDefered flag which will avoid doing unnecessary serialisation of the Java objects inside the ObjectMessage instances.

Reduce CPU Usage: Use OpenWire loose encoding

By default ActiveMQ uses tight encoding with ActiveMQ. This encoding method uses more CPU but produces smaller packets. In most enviroments this works well. In some other enviroments where bandwith is not an issue and CPU usage is the constraint, switching to loose encoding should help reduce CPU usage.

For more assistance

The FUSE forum is available for any questions you may have.

分享到:
评论

相关推荐

    weblogic平台J2EE调优策略

    1.4 JMS代码调优 1.4.1 注意必要的事项,避免使用不必要的特征 1.4.2 消息类型的选择 1.4.3 确认方式的选择和JMS事务 1.5 EJB代码调优 1.5.1 有效使用设计模式 1.5.2 使用EJB和WebLogic的特性 1.5.3 缓存资源 1.5.4 ...

    [Liferay] Liferay Portal 性能调优最佳实践 (英文版)

    [Packt Publishing] Liferay Portal 性能调优最佳实践 (英文版) [Packt Publishing] Liferay Portal Performance Best Practices (E-Book) ☆ 出版信息:☆ [作者信息] Samir Bhatt [出版机构] Packt Publishing...

    JMS(JMS(JMS(JMS(

    JMS(JMS(JMS(JMS(JMS(JMS(JMS(JMS(JMS(JMS(JMS(JMS(JMS(JMS(JMS(JMS(JMS(JMS(JMS(JMS(JMS(JMS(JMS(JMS(JMS(JMS(JMS(JMS(JMS(JMS(JMS(JMS(JMS(JMS(JMS

    javax.jms.jar

    Classes contained in javax.jms.jar: javax.transaction.xa.XAResource.class javax.jms.BytesMessage.class javax.jms.Message.class javax.jms.JMSException.class javax.jms.Destination.class javax.jms....

    javax.jms.jar下载

    javax.jms.BytesMessage.class javax.jms.Connection.class javax.jms.ConnectionConsumer.class javax.jms.ConnectionFactory.class javax.jms.ConnectionMetaData.class javax.jms.DeliveryMode.class javax.jms....

    JMS578多达13个固件打包升级工具包 可修改休眠时间

    文件包含: 13个不同固件 两个固件升级工具 其中一个是量产工具可以修改休眠时间和盒子信息 TRIM检查工具 有几个固件版本为全网首发,别人没有的资源 固件列表: JMS578_00.01.00.05 ...JMS578_254.02.03.09_NoUAS

    JMS561U.PcbLib AD封装测试可用

    JMS561U.PcbLib AD封装测试可用,给大家分享一下,。。。。

    jms-1.1.jar(jms工具jar包)

    jms工具jar包,使用jms需要的jar包(jms工具jar包,使用jms需要的jar包)

    JMS578 windows烧录工具,JMS578FwUpdate,固件,相关文档

    JMicron JMS578 USB/SATA bridge JMS578介绍手册JMS578_Product+Brief.pdf JMS578固件(支持Android系统/linux系统) JMS578 windows的烧录工具和JMS578FwUpdate JMS578-Hardkenel-Release-v173.01.00.02-20190306....

    weblogic笔记

    weblogic笔记包括: weblogic 的性能调优 weblogic 与JVM的配合 weblogic JMS与集群之间的关系 apache的性能调优 apache研究安全性与吞吐量

    JMS消息模型 JMS学习.doc

    JMS学习好的帮助文档。需要的同学下载。 概述……………………………………………………………………………………………..3 体系结构………………………………………………………………………………………..4 JMS...

    PDS-17001_JMS583_Datasheet_(Rev._1.0)_JMS583_jmicron_jms583开发_

    Jmicron JMS583 Datasheet USB 3.1 Gen 2 to PCIe Gen3x2 Bridge

    javax.jms.jar包与JMS实例代码

    包含JMS必需的javax.jms.jar包,以及jms基础实例代码。

    javax.jms包,sun的JMS接口规范包,版本1.1

    javax.jms包,sun的JMS接口规范包 2018年6月4日17:05:30

    JMS583编程器固件备份

    JMS583编程器固件备份,用于USB-NVME的固态硬盘桥接方案。nvme USB硬盘盒JMS583方案在市面上占有率很高,出现掉固件的情况可能会有,可以用编程器烧录试试。

    绿巨能JMS578硬盘盒刷固件

    绿巨能JMS578硬盘盒刷固件

    JMS 简介以及Weblogic配置JMS图解

    JMS 简介以及Weblogic配置JMS图解

    spring jms 整合 weblogic jms

    本人开发的spring jms项目,已经上线近一年了,这里是我项目jms配置文件,使用的是spring jms 整合weblogic jms。如果真的需要,请咨询我,并且附上我上传的这个配置文件,附近中没有带有这个文件,一律不作任何回答...

    硬盘盒JMS578更新固件 休眠修改

    硬盘盒JMS578更新固件 休眠修改

    JMS硬盘盒固件3.5寸通用

    JMS567用于硬盘盒3.5寸刷机,567芯片,可备份 JMS567用于硬盘盒3.5寸刷机,567芯片,可备份

Global site tag (gtag.js) - Google Analytics