Skip to content

Latest commit

 

History

History
32 lines (22 loc) · 1.59 KB

queue-rate-limiting.md

File metadata and controls

32 lines (22 loc) · 1.59 KB

RedisSMQ / Docs / Queue Rate limiting

Queue Rate limiting

In some cases consuming messages with a high message rate may be not desirable. For example:

  • A high rate of message consumption may create some problems for your application.
  • Your application is consuming messages with a high rate, however a high level of resources is being used which affects the overall performance of your system.
  • Your application is using an external API which is rate-limiting client requests and consuming messages with a high rate could make your service banned for a certain time or maybe permanently.
  • Etc.

RedisSMQ allows you, in such cases, to control the rate at which the messages are consumed by setting a rate limit for a given queue.

To configure and view rate limiting parameters for a queue, the QueueRateLimit Class provides the following methods:

Example

const { QueueRateLimit } = require('redis-smq');

const queueRateLimit = new QueueRateLimit();
// Setting a rate limit of 200 msg/min for the 'notofications' queue
queueRateLimit.set('notifications', { limit: 200, interval: 60000 }, (err) => {
  // ...
})

Queue rate limiting parameters can be also configured using the HTTP API Interface or from your browser with the help of the Web UI.