Introducing Dragonfly Cloud! Learn More

Error: redis not evicting

What's Causing This Error

The 'redis not evicting' error is typically encountered when your Redis instance is running out of memory and it's not able to evict keys to make more space. This can happen due to a number of reasons. One common cause is incorrect configuration: by default, Redis doesn't evict keys; you have to explicitly configure it to do so by setting a maxmemory policy. Another possible cause is that the set maxmemory policy isn't triggered because the specified limit hasn't been reached yet, or the eviction policy isn't effective enough for your workload. For example, if the 'allkeys-lru' policy is set but all keys are regularly accessed, then the Least Recently Used (LRU) algorithm might not free up much space.

Solution - Here's How To Resolve It

To solve the 'redis not evicting' error, first, ensure that a maxmemory limit is set on your Redis configuration. If it's not set, Redis will continue to use the system's memory until it's exhausted. Choose an appropriate value considering your system's total available memory and other operations that might need memory. If there's already a maxmemory limit in place, reconsider the eviction policy. The 'noeviction' policy will lead to errors once the memory limit is reached. So, choose among other policies like 'allkeys-lru', 'volatile-lru', 'allkeys-random', 'volatile-random', or 'volatile-ttl' depending upon your application's specific needs. Remember, each policy has its own trade-offs. Finally, monitor your keys' access pattern and the size of stored data. Try to optimize your data storage and access patterns to prevent unnecessary memory consumption.

Was this content helpful?

Start building today 

Dragonfly is fully compatible with the Redis ecosystem and requires no code changes to implement.