ActiveMQ - performance tuning - general

What's delivery mode, which one is the default?
java

- The JMS spec allows for 2 delivery modes: persistent and non-persistent, the default mode is persistent.session


Why non-peristent mode is faster?socket

  1. message producer doesn't have to wait for a receipt from the broker.async

  2. persisting messages to message store is slow compared to messaging over network.tcp


Hot to set non-persistent?this

MessageProducer producer = session.createProducer(topic);
producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);


Why we batch up production of messages?code

- Only the transaction boundary results in synchronous communication with the message broker.orm

So, we can batch up the production of messages.ip

Session session = con.createSession(true, Session.SESSION_TRANSACTED);
...
session.commit();


What transport should we use if the service that's dependent on a message broker co-locate with it?rem

- VM transport. Because messages delivered through a broker don't incur the cost of being serialized on the wire to be transported across the network.


What is OpenWire? How to tune this protocol?

- OpenWire is the default wire format used in ActiveMQ. 

- how to tune[default]:

  1. tightEncodingEnabled=false: this will disable CPU-intensive way to compact messages. [true]

  2. cacheEnabled=false: this will disable cache. Caching is good to remove repeated values from messages which improve the performance over network but cache look will bring about CPU load. [true]

.....

How to tune TCP transport?

  1. socketBufferSize: Usually the bigger the better. [65536]

  2. tcpNoDelay: normally a TCP socket buffers up small pieces of data before being sent. When we enable this option, messages will be sent ASAP.

Both above items are OS-dependent, it's worth testing!!


If we use Persistent delivery mode, how to tune?

- asynchronous send. This will tell producer not to expect receipt from broker that the message is on disk

相關文章
相關標籤/搜索