Redis Performance Tips

Optimizing Redis performance

Pipelining

# Send multiple commands at once
redis-cli --pipe # use pipeline mode
# Reduces network round trips

Memory Optimization

MEMORY USAGE key # memory used by key
MEMORY DOCTOR # memory usage report
MEMORY STATS # memory statistics

Slow Log

SLOWLOG GET 10 # get 10 slowest queries
SLOWLOG LEN # number of slow queries
SLOWLOG RESET # clear slow log
CONFIG SET slowlog-log-slower-than 10000 # microseconds threshold

Client List

CLIENT LIST # list connected clients
CLIENT KILL ip:port # disconnect client

Monitor

MONITOR # stream all commands (debugging only)

Best Practices

# Use pipelining for multiple commands
# Avoid KEYS in production (use SCAN)
# Use connection pooling
# Set appropriate maxmemory and eviction policy
# Use Redis data structures efficiently