Details
Description
When there are many consumers (~188k) on a queue, closing them is incredibly expensive and causes the CPU to spike to 100% while the consumers are closed. Tested on an Amazon MQ mq.m5.large instance (2 vcpu, 8gb memory).
I have attached a minimal recreation of the issue where the following happens:
1/ Open 100 connections.
2/ Create consumers as fast as we can on all of those connections until we hit at least 188k consumers.
3/ Sleep for 5 minutes so we can observe the CPU come back down after opening all those connections.
4/ Start closing consumers as fast as we can.
5/ After all consumers are closed, sleep for 5 minutes to observe the CPU come back down after closing all the connections.
In this example it seems 5 minutes wasn't actually sufficient time for the CPU to come back down and the consumer and connection counts seem to hit 0 at the same time:
In a previous test with more time sleeping after closing all the consumers we can see the CPU come back down before we close the connections.