Deleting Large Objects in Redis

In Redis, deleting large non-string objects like hashes, lists, sets, and sorted sets can block your server for significant amounts of time, potentially causing problems like client-side timeouts. This is due to two aspects of the way Redis works:

  • Redis is single-threaded. This means that it can only process one command at a time no matter how many clients you have connected. If a command takes a long time to run, every other command will need to wait.

  • DEL is an O(n) operation on hashes, lists, sets and sorted sets. This means that an object with 1 million elements will take roughly 10,000x longer to delete than a similar object of the same type with 100 elements.

Fortunately, Redis gives us some tools we can use to delete large objects without blocking the server for extended amounts of time. We’ve compiled our solutions here:

Explore Your Redis Memory Usage with an Interactive Map

RedisMonitor from RedisGreen shows you large keys, memory leaks, old keys, and other potential problems quickly. Try it now, no credit card required!

Last updated 09 Jun 2015. Originally posted 09 Jun 2015 by Tyson Mote

← Back to docs