ApsaraDB for Redis provides the client-output-buffer-limit pubsub parameter for you to specify a size limit for output buffers of Pub/Sub clients. If the data to be buffered for a Pub/Sub client exceeds the size limit, ApsaraDB for Redis closes the connection to the client. This prevents the buffered data from consuming an excessive amount of memory and ensures the performance of ApsaraDB for Redis.

Limits on output buffers in ApsaraDB for Redis

ApsaraDB for Redis allocates an output buffer in the memory to each client. After ApsaraDB for Redis processes the commands from clients, ApsaraDB for Redis temporarily stores the result data in output buffers and then sends the result data to the clients. If you do not limit the size of data in output buffers, a large amount of data may accumulate in output buffers. The data may eventually use up all the available memory and result in a service failure. This issue may occur in the following scenarios:

  • A large amount of data needs to be returned for commands from clients.
  • Message publishing outpaces message consumption.

By setting the client-output-buffer-limit pubsub parameter to a proper value, you can prevent the output buffers of Pub/Sub clients from consuming an excessive amount of memory.

Parameter options

The client-output-buffer-limit pubsub parameter includes the following options: hard limit, soft limit, and soft seconds.

  • hard limit specifies a fixed limit. Unit: bytes. If the output buffer of a Pub/Sub client reaches or exceeds the number of bytes specified by hard limit, the client is immediately disconnected.
  • soft limit specifies a limit that depends on the time. Unit: bytes. soft seconds specifies the amount of time to continuously trigger a soft limit. Unit: seconds. If the output buffer of a Pub/Sub client reaches or exceeds the upper limit specified by soft limit for a period of time in seconds that is specified by soft seconds, the client is disconnected.

In ApsaraDB for Redis, the default values of hard limit, soft limit, and soft seconds are 33554432 bytes (32 MB), 8388608 bytes (8 MB), and 60 seconds. You can customize the values based on your business requirements and the capacities of clients.

Specify the parameter in the ApsaraDB for Redis console

  1. Log on to the ApsaraDB for Redis console.
  2. On the top of the page, select the region where the instance is deployed.
  3. On the Instances page, click the Instance ID of the instance.
  4. In the left-side navigation pane, click System Parameters.
  5. On the page that appears, find the client-output-buffer-limit pubsub parameter and click Modify in the Actions column.
    client-output-buffer-limit pubsub
  6. In the client-output-buffer-limit pubsub Policy dialog box, perform the following steps:
    1. Specify the client-output-buffer-limit pubsub parameter based on the description in Parameter options.
    2. In the dialog box that appears, click OK.
    Note After you complete the settings, you can view these settings in the ApsaraDB for Redis console. You can also use redis-cli to connect to the ApsaraDB for Redis instance and run the CONFIG GET client-output-buffer-limit command to view the settings.

Related operations

Operation Description
DescribeParameters Queries the configuration and operational parameters of an ApsaraDB for Redis instance.
ModifyInstanceConfig Modifies parameters of an ApsaraDB for Redis instance.