Skip to main content

Debugging

Redis is single-threaded (for command execution), so any blocking operation stops the server from processing other commands. This leads to:

  • High latency
  • Timeouts in applications
  • Replication lag
  • Slow clients
  • Stuck transactions
  • Load imbalance

Understanding and debugging blocking operations is crucial for Redis performance and stability.

Common Blocking Commands

A blocking operation is any Redis command that waits for something instead of responding immediately.

CommandBlocking Reason
BLPOP, BRPOP, BRPOPLPUSHWaits for elements in a list
XREAD BLOCKWaits for new messages in a stream
XREADGROUP BLOCKWaits for pending stream entries
WAITWaits for replication
DEBUG SLEEPExplicitly blocks Redis execution
Long Lua scriptsRedis cannot process other commands until script finishes
Slow commands scheduled by clientsEg. KEYS *, LRANGE biglist 0 -1, HGETALL huge_hash

To debug blocking

ToolPurpose
CLIENT LISTFind blocked clients
SLOWLOGFind slow/expensive commands
MONITORLive command stream
INFO clientsCount blocked clients
LATENCY DOCTORAnalyze latency spikes