Find connections bloating memory (output buffer, query buffer, maxmemory-clients)
RedisMemoryCommand
INFO clients
# Top 10 connections by tot-mem (tot-mem, omem, qbuf, id, addr, user, cmd, age):
redis-cli -h redis1 -p 6379 CLIENT LIST | awk '{for(i=1;i<=NF;i++){split($i,a,"="); f[a[1]]=a[2]} print f["tot-mem"], f["omem"], f["qbuf"], f["id"], f["addr"], f["user"], f["cmd"], f["age"]}' | sort -rn | head -10
CLIENT LIST TYPE pubsub
CONFIG GET client-output-buffer-limit
# Upper limit for the total memory of all clients (largest clients are closed when exceeded):
CONFIG SET maxmemory-clients 5%What it does
Sorts connections by total memory (tot-mem), output buffer (omem) and query buffer (qbuf); shows pub/sub connections and buffer limits; sets an overall upper limit for client memory.
When to use it
When used_memory grows without data growth, mem_clients_normal looks high, or a slow-consuming pub/sub/MONITOR client fills memory.
Caution
A large omem usually points to a client reading results slowly (large KEYS/HGETALL reply, slow pub/sub subscriber, a MONITOR left open). When maxmemory-clients is exceeded, the clients holding the most memory are closed without warning; replica and master links are excluded but application connections may drop. Use CLIENT NO-EVICT on for critical connections.