...

Redis Client Eviction: Controlling Memory Usage for Multiple Connections

With Redis Client Eviction You can limit the total memory used by many connections or by particularly memory-intensive connections: If this exceeds the configured threshold, Redis will attempt to disconnect memory-intensive clients first. This does not protect against every memory issue and does not directly limit the number of connections. Therefore, in addition to having an appropriate budget, it is crucial that your applications can handle disconnections and ambiguous responses. This mechanism has been available in Redis Open Source since version 7.0; for managed services, you must check the configurability separately.

Redis Connections and Their Memory Requirements

The number of open Redis Connections and their memory requirements reflect different issues. Each connection requires memory for its state and buffers. The total amount of memory required depends both on the number of connections and on the data that individual clients are currently sending and receiving.

Many small connection pools can add up to a large total number across multiple application instances. Even if each connection takes up little memory on its own, the total memory usage can become significant. Limited and reusable pools help prevent unnecessary connections; the appropriate size depends on how many concurrent requests the application actually needs to handle.

Conversely, even a single slow client can stand out. Redis stores incoming data in Input buffers and holds outgoing responses until the client reads them. In addition, there are other intermediate buffers and connection information. If Redis generates responses faster than the recipient can process them, the output buffer in particular can grow.

This is relevant, for example, when dealing with a slow Pub/Sub consumer or large responses. In such cases, the number of connections alone does not reveal which connection is consuming memory. For troubleshooting, you therefore need not only the number of connections but also information about connection memory usage and the application's behavior over a period of time.

Memory usage is also only one part of the total memory requirement. The data set and other memory areas of the Redis process—as well as any other processes in the container—must also be taken into account. Therefore, setting a limit for clients alone does not guarantee that a process or container will remain within its available memory.

How Redis Client Eviction Works

Redis Client Eviction has been available as open source in Redis since version 7.0. Before planning, check the specific server version and product variant: With a managed offering, configuration options or administrative commands may be limited. A current documentation page alone does not guarantee that every feature described there is available in exactly the same way in an older installation.

The parameter maxmemory-clients sets a aggregated threshold value for the connection memory taken into account during client eviction. If this memory exceeds the specified value, Redis attempts to close connections in order to bring the total back below the threshold. The parameter therefore does not directly limit the number of open connections.

When making this selection, Redis considers memory usage and gives priority to disconnecting particularly memory-intensive clients. It attempts to close only as many connections as necessary. This is neither a commitment to a specific selection nor a guarantee of availability: An affected application must be able to handle the loss of its connection.

Master and replica connections are exempt from this client eviction. This is another reason why you should not confuse the threshold with a hard upper limit for each connection-related memory resource or even for the entire process. Additional headroom is required for sizing.

Shutting down memory-intensive clients can reduce the load on the server, but it shifts part of the problem to the application: Ongoing requests may be interrupted, and a new connection must be established. The extent of this impact depends on the specific message flow and on whether the application can detect lost or incomplete transactions.

Client Eviction and Key Eviction

In the case of client eviction, the immediate consequence is a Connection Lost. Redis closes a client to free up allocated connection memory; this alone does not automatically delete a key. The application must still decide how to handle interrupted requests and reconnections.

Key Eviction, on the other hand, affects the data set. If Redis reaches the configured maxmemory-limit, determined maxmemory-policy, how Redis handles keys under this storage pressure. Depending on the policy, keys may be removed; if the policy does not allow overwriting, certain write commands that increase storage usage may fail instead.

The two mechanisms thus serve different purposes. A suitable Key Eviction Policy It determines the key, but does not limit memory-intensive clients on its own. Conversely, a client limit does not replace the decision about which data may be displaced when memory is scarce and what consequences that would have for the application.

For a cache, removing individual keys may be acceptable, for example, if the application retrieves the data again as needed. A connection failure is a different type of disruption: in this case, access may fail before the application even has a chance to handle a missing key. Both cases should therefore be considered separately.

Which keys are removed first under a given policy depends on the selected strategy. The supplementary Comparison of Redis LFU and LRU explains this selection for the dataset. It does not replace the need to plan for connection buffer budgets or to handle client disconnections.

Examine Connections and Storage

Before making a change, you need a Inventory Under typical load and, if possible, also during known load peaks. First, check the Redis product and server version, as well as the permissions for the read-only INFO, CONFIG, and CLIENT commands. For managed services, certain commands or parameters may be restricted; check with the provider to determine the available diagnostic methods.

Enter the following lines one at a time in a Redis CLI session connected to the instance you want to examine. These are read-only queries, not terminal commands or configuration changes. Run CLIENT LIST Select them specifically when you need to assign connections more precisely.

Code
INFO clients
INFO memory
INFO stats
CONFIG GET maxmemory
CONFIG GET maxmemory-clients
CLIENT LIST

If the target version outputs the fields, make sure to connected_clients for the number of clients, mem_clients_normal for the memory of standard clients and evicted_clients for connections terminated by client eviction. Check the field definitions for your version: The memory value is not equivalent to the total process memory.

AI-generated stock image of a patch panel with several Ethernet cables connected to it
AI-generated stock image: For many networks, a targeted assessment helps identify suspicious clients.

A single data point does not explain either the cause or the trend. Compare the values over time with application load and reported connection drops. For example, if connection memory increases while the number of clients remains largely stable, it’s worth investigating individual memory-intensive connections; if, on the other hand, the number of clients is the primary factor driving the increase, also check the application pools.

CLIENT LIST can provide information such as names, idle times, and storage details for mapping purposes. The computational load increases with the number of connections; therefore, on a heavily loaded instance, this query should be planned carefully. The output may contain sensitive connection information: Review it before sharing it, and do not publish any login credentials.

Configure maxmemory-clients securely

For maxmemory-clients you can enter 0, an absolute memory value, or a percentage of maxmemory Set this value. A value of 0 disables client eviction. An absolute value sets the threshold regardless of the percentage calculation; a percentage value requires a properly configured `maxmemory` base.

The Reference value is important for making this decision: With `maxmemory` configured to 2 GiB, 5% theoretically equals 0.1 GiB, or 102.4 MiB. This is an illustrative calculation, not a measurement or a recommendation for a production instance. The threshold does not guarantee an upper limit for either the entire Redis process or the container.

For an isolated Redis open-source test instance with `maxmemory` set appropriately, you can include the following line in its configuration file. This value is a starting point for testing behavior; it does not assume that all applications can tolerate connection drops. Check in advance whether the version you’re using and your configuration method support this parameter.

Code
maxmemory-clients 5%

Redis also supports runtime modification using CONFIG SET. However, this does not replace the need to verify how your configuration is loaded during a restart or deployment. Any permanent change must be made through the configuration and approval process designated for the environment; for Managed Redis, the provider’s approval is also required.

During testing, pay particular attention to client memory, evictions, and how applications respond to disconnected connections. Before deploying this in production, you’ll need monitoring, a coordinated rollout, and a fallback plan—for example, to restore the previously valid value. Also plan how affected applications will continue to function after a disconnection.

Comparison of Limits and Policies

The parameters take effect in different ways. A limit on the number of Redis connections does not necessarily prevent individual connections from consuming a lot of memory. Conversely, an aggregated memory threshold does not directly limit the number of connections. The following overview helps you identify what each setting controls before making a change.

Redis Security Mechanisms and Their Limitations
mechanismSubject Matter of the RegulationCause or EffectUse caseSignificant Limit
maxmemory-clientsAggregate client storage taken into accountIf the limit is exceeded, memory-intensive clients are disconnected firstSecure the connection cacheNo direct limit on the number of clients; replication connections excluded
maxclientsNumber of client connectionsAdditional connections will be rejected at the limitLimit the number of connectionsNo storage limit per connection
client output buffer limitOutput buffers for individual connectionsDisconnection if the applicable buffer limit is exceededLimit Slow ReadersDoes not include the entire aggregated client storage
timeoutInactive Normal ConnectionsCloses after the configured inactivity time has elapsedReduce Unused ConnectionsDoes not apply to Pub/Sub and is not accurate to the second
maxmemory policyKey when maxmemory is reachedSpecifies key displacement or behavior without displacement, depending on the policyChoose a Data Storage StrategyDoes not solve client storage problems on its own

A Output Buffer Limit It takes effect per connection and can limit a slow client before its output buffer continues to grow. The aggregated client limit complements this protection because even many connections that are individually inconspicuous can collectively consume a lot of memory. Both mechanisms can trigger connection terminations and require appropriate handling within the application.

When planning maxclients, the available File descriptors. A higher connection limit does not automatically provide additional operating system resources or a larger memory budget. Therefore, check pool sizes and system limits together, rather than simply resolving an error message about too many clients by increasing the parameter.

An idle timeout can terminate unused normal connections, but it is not a general memory limit. It does not apply to Pub/Sub clients; furthermore, the check is not performed with second-level precision. An active subscriber that reads slowly therefore requires separate consideration of its output buffers and the consequences of a potential disconnection.

Offload Pools and Slow Clients

The total number of Redis connections often results from many individual application pools. For example, if you’re running eight application instances, each with a maximum of 20 pool connections, these pools alone can open up to 160 connections. Additional workers, management tools, and other services may also be involved. This calculation describes a possible upper limit, not an actual measurement.

Limit the Pool Size Optimize for concurrent processing and reuse existing connections instead of establishing a new one for each request. Also take into account additional instances when scaling. A pool that is too small can cause requests to be put on hold; conversely, an unnecessarily large pool increases the number of possible connections and their combined memory requirements.

A single slow Pub/Sub subscriber can also become a problem: If Redis produces messages faster than the subscriber can read them, the subscriber’s output buffer grows. Therefore, check both the subscriber’s processing speed and the output buffer limit applicable to Pub/Sub. The aggregated client limit provides additional protection, but it does not resolve the slow message flow.

AI-generated illustration of small discs piling up in front of a narrow opening
AI-generated illustration: A slow Pub/Sub consumer can cause the output buffer to grow.

If the subscriber is disconnected, messages may be missing during the interruption. Reconnection alone does not guarantee gap-free reception. If the message flow cannot tolerate any gaps, the application must provide a suitable mechanism for permanent storage and reprocessing, and test its behavior separately.

Even standard clients can consume a lot of output memory due to large responses or extensive pipelining. Smaller response sizes and pipeline batches, as well as faster reading, can reduce this pressure. You can determine which combination works best for your load by observing performance under representative conditions; a fixed batch size isn’t suitable for every application.

Recognizing Miscarriages and Treating Them Safely

A single memory value alone does not explain why connections become suspicious. Comparisons in the Time Series the number of clients and the memory usage of normal clients, along with application load and reported connection drops. If memory usage increases without a corresponding increase in the number of clients, it is particularly worthwhile to look for individual connections with large buffers.

Also, keep an eye on the counter evicted_clients, provided your Redis version reports it. An increase indicates client evictions during the period in question; on its own, it does not identify the responsible application or the reason for its memory usage. Cross-reference the timing with deployments, traffic spikes, and application errors.

Applications should detect connection losses and support reconnection with a limited number of retries and wait times. However, this does not automatically prevent overload or data gaps. Also check whether many clients might log back in simultaneously after a disconnection, thereby creating a new peak in load.

Special caution is required for write operations: If no response is received, it may be unclear whether Redis has already executed the command. An unchecked retry can trigger an effect twice. Therefore, for each operation, specify whether it can be safely retried or whether the application must check its state or a unique transaction ID.

For a critical operational connection, you can CLIENT NO-EVICT ON the current connection Protect against client eviction. After a restart, the application must re-enable protection on the new connection. The command does not prevent other causes of connection loss; protected clients continue to consume memory, so use it sparingly.

Before use, check the administrative permissions and product compatibility. The Redis command reference specifies CLIENT NO-EVICT as incompatible with the versions of Redis Software and Redis Cloud listed there. For other managed offerings, the respective provider's approval is required.

Define Threshold Values and Operating Concepts

Place the Storage Budget This limit is not fixed in isolation for clients: In addition to connection buffers, Redis requires memory for data and other tasks; the process and container also need reserves. Therefore, setting a limit for clients does not guarantee that the entire process will remain within a specific memory limit. Plan based on the observed load and the available operating environment.

The 5% figure mentioned in the Redis documentation is a possible starting point for large installations, not a general recommendation. When setting a percentage value, you must maxmemory be actually configured as a meaningful reference value. Whether the resulting threshold is appropriate for your clients depends, among other things, on their buffering requirements and the tolerable number of disconnections.

Before implementation, determine which applications can tolerate a disconnection and what the consequences are of an interrupted message flow or an unclear write response. Then test with a representative load in an isolated environment—for example, using multiple pools, slow readers, and large responses. While doing so, monitor not only Redis but also errors and reconnections on the application side.

Set up a Alerting Establish procedures for handling unusual memory usage trends and increasing client evictions, and designate responsible individuals and response protocols. Implement changes incrementally and have a fallback plan ready that takes into account the previous state and the actual configuration and deployment process. After each change, monitor the performance trends and behavior of the applications.

With a managed service offering, you should also check which parameters and administrative commands the provider enables for your product variant. To help you make the separate decision regarding keys under storage pressure, the Choosing a Redis Key Eviction Strategy. It does not replace either the client limit or a plan for connection terminations.

Sources and Current State of Knowledge

Status of the research:

This is based on Redis Open Source version 7.0 or later; commands, INFO fields, and managed compatibility must be verified for the specific product variant and server version being used. Research date: November 16, 2026.

https://redis.io/docs/latest/develop/reference/clients/

https://redis.io/tutorials/operate/redis-at-scale/talking-to-redis/

https://redis.io/docs/latest/develop/reference/eviction/

https://redis.io/docs/latest/commands/info/

https://redis.io/docs/latest/develop/reference/errors/common/err-max-clients/

https://redis.io/docs/latest/commands/client-no-evict//

Current articles