Databases 3 min read

How Redis Manages Client Output Buffers to Prevent Memory Overload

Redis allocates a dedicated output buffer for each client—whether a regular user, slave, monitor, or Pub/Sub subscriber—and employs size and duration limits to automatically close connections when buffers grow too large, thereby preventing memory exhaustion and potential system crashes.

Java High-Performance Architecture
Java High-Performance Architecture
Java High-Performance Architecture
How Redis Manages Client Output Buffers to Prevent Memory Overload

Redis allocates an output buffer for each client connection, providing a dedicated space for the client’s response data.

The client can be a regular user client, a slave, or a monitor.

After processing a request, Redis copies the response into the client’s output buffer and then proceeds to the next request while the client reads the data over the network.

If the output buffer is not properly controlled, it may consume excessive memory and cause system crashes, for example when a simple command generates a huge reply or when the rate of generated replies exceeds the rate at which they are sent to the client, leading to buffer accumulation.

To prevent this, Redis implements protection mechanisms with size and duration limits that differ by client type.

Two limiting methods are used: (1) a size limit that closes the client connection when its buffer exceeds a threshold, and (2) a time‑based limit that closes the connection when the buffer remains excessively large for a certain period.

Policies per client type are:

Ordinary clients have no limit (size 0) and typically use a blocking request‑response pattern, which rarely causes buffer buildup.

Pub/Sub clients have a size limit of 32 MiB; connections are closed if the buffer exceeds 32 MiB or if it stays above 8 MiB for 60 seconds.

Slave clients have a size limit of 256 MiB; connections are closed if the buffer stays above 64 MiB for 60 seconds.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

redisconnection limitsmemory protectionclient managementoutput buffer
Java High-Performance Architecture
Written by

Java High-Performance Architecture

Sharing Java development articles and resources, including SSM architecture and the Spring ecosystem (Spring Boot, Spring Cloud, MyBatis, Dubbo, Docker), Zookeeper, Redis, architecture design, microservices, message queues, Git, etc.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.