Skip to content

Instantly share code, notes, and snippets.

@ivermac
Last active November 26, 2018 05:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ivermac/d625b683599f39bdd1f9c0503e4322c2 to your computer and use it in GitHub Desktop.
Save ivermac/d625b683599f39bdd1f9c0503e4322c2 to your computer and use it in GitHub Desktop.
Redis Client Debugging 101

If you are using redis and wanted to check how many open connections are there at the moment, use the client list command in your redis terminal.

127.0.0.1:6379> client list
id=936 addr=127.0.0.1:61277 fd=8 name= age=3 idle=0 flags=N db=0 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=32768 obl=0 oll=0 omem=0 events=r cmd=client

This is a powerful debugging tool especially when you have an app that's using redis and seems to be opening connections without closing them, meaning you run out of memory in your redis host server.

Before getting to this stage, a colleague in the SRE team had used the following command to identify the redis problem

lsof | grep <user> | grep TCP | grep 6379

The command helped us identify that our app was opening connections to redis without closing them but we didn't know what exactly was causing this since we had functionality that opened and closed connections. The client list command helped us to know what command was being triggered from our app - cmd field in the output of client list command - that wasn't being closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment