This topic describes how to query transactions per second (TPS) charts based on the message operation logs that are generated for a Message Queue for RabbitMQ instance. If the maximum number of requests that you can send per second without being throttled is exceeded, you can query second-level TPS charts based on the methods described in this topic. This can help you identify exceptions and ensure availability of your business.
Prerequisites
Background information
The number of requests that are sent by calling the following AMQP methods can be counted as the TPS:
- ConnectionOpen and ChannelOpen
- QueueDeclare, QueueDelete, QueueBind, and QueueUnbind
- ExchangeDeclare and ExchangeDelete
- ExchangeBind and ExchangeUnBind
- SendMessage, BasicConsume, BasicGet, BasicAck, BasicReject, BasicNack, and BasicRecover
For more information about the request methods, see Request methods.
Procedure
(Action : ConnectionOpen or Action : ChannelOpen or Action: ExchangeDeclare or Action: QueueBind or Action : QueueDeclare or Action : QueueDelete or Action : ExchangeDelete or Action : QueueUnBind or Action : ExchangeBind or Action : ExchangeUnBind or Action : BasicConsume or Action : BasicReject or Action : BasicRecover or Action : SendMessage or Action : BasicAck or Action : BasicNack or Action : BasicGet ) | select from_unixtime(cast(microtime as bigint)/1000/1000) as time, COUNT(*) as count GROUP by time ORDER by time limit 90000000

- If the client calls BasicNack with the multiple=false setting, a request is sent for each call. If the client calls BasicNack with the multiple=true setting, multiple requests are sent for each call. However, Log Service creates only a log entry for a BasicNack call, regardless of whether multiple requests are sent for a call. Therefore, the TPS returned in a TPS chart is smaller than the actual TPS.
- When you query a TPS chart, if a large amount of traffic is received by your client,
we recommend that you specify a time range that is less than or equal to 1 hour and
add
limit 90000000
to the SQL statement that is executed to query the TPS chart. You can also replace 90000000 in limit with the largest possible value.