How to Load Balancing AMQP Producers/Consumers in Cluster ?
Environment
- Red Hat AMQ
- 7.4.3
Issue
-
We have some AMQP clients using the qpid-jms libraries and we were wondering if we could get some feedback on how we can best load balance their producers and consumers in a clustered broker setup.
-
The application currently utilizes a failover URI to specify each broker in the cluster (currently three broker cluster). For whatever reason, sometimes we end up with 100 consumers on a given queue on broker A and 20 consumers on the same queue on broker B. Because we are using ON_DEMAND load balancing, any messages produced to that queue end up being split 50/50 to the queues in both broker A and broker B. However, because broker B has only 20 consumers on the queue they end up falling behind and the queue backs up.
-
We are wondering what the best practice to handle this sort of situation is. Normally we would utilize something like the priorityBackup option with openwire libraries to move the consumers back to a particular broker but the qpid-jms libraries don't seem to support that option. We of course could just pin the consumers to a single broker and not have them specify all three brokers in the failover URI, but then they would be bound to a single endpoint which reduces their HA options.
Resolution
- You should use following configuration
failover.randomize
If enabled, the set of failover URIs is randomly shuffled before attempting to connect to one of them. This can help to distribute client connections more evenly across multiple remote peers. It is disabled by default.
- These options are described in official documentation[1].
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.
Comments