Updated on 2025-07-14 GMT+08:00

Testing RabbitMQ Production and Consumption Rate

This section describes performance tests on Distributed Message Service (DMS) for RabbitMQ. The performance is measured by the instance flavors, SSL, producer/consumer quantity, queue quantity and type, and exchange type. The tests cover the following scenarios:

  • Test scenario 1 (instance flavors): same exchange, queue, number of producers and consumers, but different instance flavors
  • Test scenario 2 (whether SSL is enabled): same exchange, queue, number of producers and consumers, instance flavors, but SSL enabled/disabled
  • Test scenario 3 (number of producers/consumers): same exchange, queue, instance flavors, but different numbers of producers and consumers
  • Test scenario 4 (single-queue and multi-queue): same exchange, number of producers and consumers, instance flavors, but different number of queues
  • Test scenario 5 (queue type): same exchange, number of producers and consumers, instance flavors, but different queue types
  • Test scenario 6 (fanout exchange): same instance flavors, fanout exchange, number of queues, but different number of producers and consumers

The test result may vary by the network or client conditions.

Test Environment

Perform the following steps to set up the test environment.

  1. Purchase cluster RabbitMQ 3.8.35 instances with parameters described in Table 1. For details about how to purchase them, see Buying a RabbitMQ Instance.
    • You are not advised to set a RabbitMQ password with special characters. If special characters are used, they need to be translated before using test scripts. Otherwise, errors occur.
    • Enable public access and allow port 15672 in the inbound rules of the security group when purchasing a rabbitmq-2u4g instance. In this way, the management UI can be accessed in a browser.
    Table 1 Instance parameters

    Name

    Brokers

    Flavor

    SSL Enabled

    Disk Type

    rabbitmq-ssl

    3

    rabbitmq.2u4g.cluster

    Yes

    Ultra-high I/O

    rabbitmq-2u4g

    3

    rabbitmq.2u4g.cluster

    No

    Ultra-high I/O

    rabbitmq-4u8g

    3

    rabbitmq.4u8g.cluster

    No

    Ultra-high I/O

    rabbitmq-8u16g

    3

    rabbitmq.8u16g.cluster

    No

    Ultra-high I/O

    rabbitmq-16u32g

    3

    rabbitmq.16u32g.cluster

    No

    Ultra-high I/O

    Obtain the private connection addresses on the RabbitMQ instance details page and record the username and password. In addition to a rabbitmq-2u4g instance, record the management UI address for later use.

  2. For the rabbitmq-2u4g instance, log in to the management UI and set queue mirroring, lazy queues, and quorum queues.
  3. In the / virtual host of the rabbitmq-2u4g instance, create a fanout exchange. For details, see Creating a RabbitMQ Exchange.
  4. Obtain the test tool rabbitmq-perf-test-2.18.0-bin.tar.gz.
  5. Purchase a client server.

    The region, AZ, VPC, subnet, and security group should be consistent with the RabbitMQ instance. The specification is 16 vCPUs | 32 GB. The server is a Linux ECS. For details, see Purchasing a Custom ECS.

    Perform the following operations on the ECSs:

    • Install Java JDK and configure the environment variables JAVA_HOME and PATH.
      export JAVA_HOME=/root/jdk1.8.0_231 
      export PATH=$JAVA_HOME/bin:$PATH
    • Download rabbitmq-perf-test-2.18.0-bin.tar.gz and decompress it.
      tar -zxvf rabbitmq-perf-test-2.18.0-bin.tar.gz

Test Script

  • The test script creates a "direct" exchange and a non-persistence queue with automatic deletion enabled. To test fanout exchanges and quorum queues, append "--predeclared" in the script which indicates that custom exchanges and queues are used.
  • To test instances with SSL enabled, change "amqp://" to "amqps://" to encrypt data transmission.

Single-queue test script:

./runjava com.rabbitmq.perf.PerfTest -h amqp://{instance username}:{instance password}@{private connection address} -e {exchange name} -s 1024 -u {queue name} -x {producer count} -y {consumer count} -z {running time}
Table 2 Test script parameters

Parameter

Description

Instance username

Username set in 1.

Instance password

Password set in 1.

Private connection address

Private connection address obtained in 1.

Exchange name

Name of the exchange to be tested.

Queue name

Name of the queue to be tested.

Producer count

Number of producers.

Consumer count

Number of consumers.

Running time

Running duration of the script, in seconds.

Multi-queue test script:

./runjava com.rabbitmq.perf.PerfTest -h amqp://{instance username}:{instance password}@{private connection address} -e {exchange name} -s 1024 -x {producer count} -y {consumer count} -z {running time} --queue-pattern 'queue-%d' --queue-pattern-from 1 --queue-pattern-to x
Table 3 Test script parameters

Parameter

Description

Instance username

Username set in 1.

Instance password

Password set in 1.

Private connection address

Private connection address obtained in 1.

Exchange name

Name of the exchange to be tested.

Producer count

Number of producers.

Consumer count

Number of consumers.

Running time

Running duration of the script, in seconds.

queue-%d

Indicates multiple queues. The queue name prefix is queue-. %d is a variable ranging from the --queue-pattern-from value to the --queue-pattern-to value, in integers.

For example: --queue-pattern 'queue-%d' --queue-pattern-from 1 --queue-pattern-to 3 indicates three queues. The queue names are queue-1, queue-2, and queue-3.

Test Procedure

  1. Log in to the client server and go to the rabbitmq-perf-test-2.18.0/bin directory.
  2. Run the following script to test and record the production and consumption rates of different instance flavors:

    ./runjava com.rabbitmq.perf.PerfTest -h amqp://{instance username}:{instance password}@{private connection address} -e {exchange name} -s 1024 -u {queue name} -x 3 -y 3 -z 300

    Example:

    ./runjava com.rabbitmq.perf.PerfTest -h amqp://test:******@192.168.0.150:5672 -e exchange-direct -s 1024 -u queue-1 -x 3 -y 3 -z 300

  3. Run the following script to test and record the production and consumption rates of the "rabbitmq-ssl" instance based on the number of producers, consumers, and queues.

    Single-queue test script:
    ./runjava com.rabbitmq.perf.PerfTest -h amqps://{instance username}:{instance password}@{private connection address} -e {exchange name} -s 1024 -u {queue name} -x {producer count} -y {consumer count} -z 300

    Example:

    ./runjava com.rabbitmq.perf.PerfTest -h amqps://test:******@192.168.0.150:5671 -e exchange-direct -s 1024 -u queue-1 -x 1 -y 1 -z 300

    Multi-queue test script:

    ./runjava com.rabbitmq.perf.PerfTest -h amqps://{instance username}:{instance password}@{private connection address} -e {exchange name} -s 1024 -x 3 -y 3 -z 300 --queue-pattern 'queue-%d' --queue-pattern-from 1 --queue-pattern-to x

    Example:

    ./runjava com.rabbitmq.perf.PerfTest -h amqps://test:******@192.168.0.150:5671 -e exchange-direct -s 1024 -x 3 -y 3 -z 300 --queue-pattern 'queue-%d' --queue-pattern-from 1 --queue-pattern-to 3

  4. Run the following script to test and record the production and consumption rates of the "rabbitmq-2u4g" instance based on the number of producers, consumers, and queues.

    Single-queue test script:
    ./runjava com.rabbitmq.perf.PerfTest -h amqp://{instance username}:{instance password}@{private connection address} -e {exchange name} -s 1024 -u {queue name} -x {producer count} -y {consumer count} -z 300

    Example:

    ./runjava com.rabbitmq.perf.PerfTest -h amqp://test:******@192.168.0.150:5672 -e exchange-direct -s 1024 -u queue-1 -x 1 -y 1 -z 300

    Multi-queue test script:

    ./runjava com.rabbitmq.perf.PerfTest -h amqp://{instance username}:{instance password}@{private connection address} -e {exchange name} -s 1024 -x {producer count} -y {consumer count} -z 300 --queue-pattern 'queue-%d' --queue-pattern-from 1 --queue-pattern-to x

    Example:

    ./runjava com.rabbitmq.perf.PerfTest -h amqp://test:******@192.168.0.150:5672 -e exchange-direct -s 1024 -x 3 -y 3 -z 300 --queue-pattern 'queue-%d' --queue-pattern-from 1 --queue-pattern-to 3

  5. Run the following script to test and record the number of producers, consumers, queues, and production and consumption rates of the "rabbitmq-2u4g" instance. The queue types are lazy, mirroring, and quorum.

    Single-queue test script (excluding quorum queues):
    ./runjava com.rabbitmq.perf.PerfTest -h amqp://{instance username}:{instance password}@{private connection address} -e {exchange name} -s 1024 -u {queue name} -x {producer count} -y {consumer count} -z 300

    Example:

    ./runjava com.rabbitmq.perf.PerfTest -h amqp://test:******@192.168.0.150:5672 -e exchange-direct -s 1024 -u queue-1 -x 1 -y 1 -z 300

    Multi-queue test script (excluding quorum queues):

    ./runjava com.rabbitmq.perf.PerfTest -h amqp://{instance username}:{instance password}@{private connection address} -e {exchange name} -s 1024 -x {producer count} -y {consumer count} -z 300 --queue-pattern 'queue-%d' --queue-pattern-from 1 --queue-pattern-to x

    Example:

    ./runjava com.rabbitmq.perf.PerfTest -h amqp://test:******@192.168.0.150:5672 -e exchange-direct -s 1024 -x 3 -y 3 -z 300 --queue-pattern 'queue-%d' --queue-pattern-from 1 --queue-pattern-to 3
    Single-queue test script (quorum queue):
    ./runjava com.rabbitmq.perf.PerfTest -h amqp://{instance username}:{instance password}@{private connection address} -e {exchange name} -s 1024 -u {queue name} -x {producer count} -y {consumer count} -z 300 --predeclared

    Example:

    ./runjava com.rabbitmq.perf.PerfTest -h amqp://test:******@192.168.0.150:5672 -e exchange-direct -s 1024 -u queue-1 -x 1 -y 1 -z 300 --predeclared

    Multi-queue test script (quorum queue):

    ./runjava com.rabbitmq.perf.PerfTest -h amqp://{instance username}:{instance password}@{private connection address} -e {exchange name} -s 1024 -x {producer count} -y {consumer count} -z 300 --queue-pattern 'queue-%d' --queue-pattern-from 1 --queue-pattern-to x --predeclared

    Example:

    ./runjava com.rabbitmq.perf.PerfTest -h amqp://test:******@192.168.0.150:5672 -e exchange-direct -s 1024 -x 3 -y 3 -z 300 --queue-pattern 'queue-%d' --queue-pattern-from 1 --queue-pattern-to 3 --predeclared

  6. Run the following script to test and record the production and consumption rates of a fanout exchange of the "rabbitmq-2u4g" instance based on the number of consumers and queues:

    Single-queue test script:

    ./runjava com.rabbitmq.perf.PerfTest -h amqp://{instance username}:{instance password}@{private connection address} -e {exchange name} -s 1024 -u {queue name} -x {producer count} -y {consumer count} -z 300 --predeclared

    Example:

    ./runjava com.rabbitmq.perf.PerfTest -h amqp://test:******@192.168.0.150:5672 -e exchange-fanout -s 1024 -u queue-1 -x 1 -y 3 -z 300 --predeclared

Test Result

The test results of the six test scenarios are as follows: