Throttling can be triggered for an ApsaraMQ for RabbitMQ instance based on the peak transactions per second (TPS) of the instance. This topic describes the throttling rules for ApsaraMQ for RabbitMQ instances, the operations performed by the consumer and producer after throttling is triggered, and the best practices that you can use for throttling.
Operations performed by the consumer and producer after throttling is triggered
If the peak TPS of an ApsaraMQ for RabbitMQ instance exceeds the TPS threshold value that is specified when you purchase the ApsaraMQ for RabbitMQ instance, throttling is triggered for the instance.
The following operations are performed after throttling is triggered:
The ApsaraMQ for RabbitMQ broker returns an error code and an error message.
The ApsaraMQ for RabbitMQ broker closes the channel of the current request. You can detect exceptions in the code and reopen the channel.
The following section describes the error code and error message:
Error code: reply-code=530
Error message: reply-text=denied for too many requests
Query the peak TPS of an instance
You can query the actual peak TPS of an instance to understand the traffic fluctuation and peak traffic of your service and determine whether the current instance specification meets your business requirements.
ApsaraMQ for RabbitMQ allows you to use the following methods to query the peak TPS of an instance:
Method | Description | Time granularity | Resource level |
(Recommended)Query the peak TPS of an instance and configure an alert rule by using CloudMonitor | Benefits:
| Peak TPS at the minute level The peak TPS of an instance during a 1-minute statistical period | Peak TPS of an instance |
(Recommended)Query the peak TPS of an instance on the instance details page |
| Peak TPS at the second level |
|
Query the peak TPS by using Log Service |
| Peak TPS at the second level | Peak TPS of an instance |
Rules based on which the TPS of an instance is calculated
If you call one of the following operations once, one TPS is counted.
- ConnectionOpen and ChannelOpen
- QueueDeclare, QueueDelete, QueueBind, and QueueUnbind
- ExchangeDeclare and ExchangeDelete
- ExchangeBind and ExchangeUnBind
- SendMessage, BasicConsume, BasicGet, BasicAck, BasicReject, BasicNack, and BasicRecover
Delayed messages are a type of advance-featured messages provided by ApsaraMQ for RabbitMQ. The number of API calls that are initiated to send and receive delayed messages is five times the number of API calls that are initiated to send and receive normal messages. Therefore, the peak TPS fee of delayed messages is five times the peak TPS fee of normal messages.
For example, if you send two delayed messages and receive three delayed messages within 1 second, the total number of API calls is 25. The number of API calls is calculated by using the following formula: 2 × 5 + 3 × 5 = 25.
When you count the number of API calls to the SendMessage operation, the actual value is the number of queues to which messages are stored after the messages are routed.
For example, if you send one message to an exchange of the Fanout type and save the message to 10 queues, the number of API calls to the SendMessage operation is counted as 10.