Skip to content

Toro Cloud Dev Center


Tuning ActiveMQ Artemis

These are some changes you can make to achieve optimum performance when using ActiveMQ Artemis as a broker for Martini Runtime.

javax.jms.ObjectMessage

As much as possible, avoid using javax.jms.ObjectMessage. This message type is convenient to use as it can contain any serializable information. However, Java serialization comes with a cost to performance and takes a lot of space. If possible, use other types such as java.jms.TextMessage, especially when you only require simple text message exchanges.

AUTO_ACKNOWLEDGE mode

Avoid using AUTO_ACKNOWLEDGE mode as much as possible. Using this mode, messages are automatically acknowledged but requires an extra message to be sent which means more traffic. Use DUPS_OK_ACKNOWLEDGE instead to lazily acknowledge messages but only if your use case allows duplicated messages. You can also use CLIENT_ACKNOWLEDGE and batch the acknowledgements at a cost of code complexity.

Durable messages

Avoid publishing durable messages if they're not needed. To survive a broker restart, durable messages require persistence which may be a waste of space if your use case does not actually need this feature.

File store

Use the recommended file store. By default, ActiveMQ Artemis uses its own file journal which is highly optimized for messaging systems. It can support JDBC persistence but using this will incur the performance overhead of using databases.

TCP buffer size

Consider configuring the TCP buffer size. Having a large buffer size increases the performance of message exchanges provided your network is fast. However, if this is too large, the buffer may accumulate more data than the application can process. If you are running on Linux, your OS may already include auto-tuning. In this case, it is better to leave the tuning to the OS.

JVM

Like Martini Runtime or any other Java application, ActiveMQ Artemis runs on a Java Virtual Machine which can be tuned for higher performance. Make sure the JVM is configured to have as much as memory it can have. Use the JVM arguments -Xms and -Xmx to set the memory. Also take advantage of parallel garbage collection by specifying -XX:+UseParallelOldGC as a JVM argument.

File handle limit

ActiveMQ Artemis can generate and open a lot files when using concurrent connections. You may reach your OS's file handle/descriptor limit. Use the command ulimit -n [number] to configure this.

Message size

Exchanging big chunks of messages may hurt your throughput. Ensure that your messages only contain the data that you need to minimize the overhead of message transfers.

To learn more about other optimizations, you can read the official performance tuning page of ActiveMQ Artemis.