# Redis Performance

> Master Redis performance - memory optimization, slow log analysis, benchmarking, monitoring, and tuning strategies

- Skill: `majiayu000/redis-performance` (Agent Skill, multi-file: 2 files)
- Install (CLI): `npx skillmds add majiayu000/redis-performance`
- Raw SKILL.md: https://api.skillmd.com/api/skills/majiayu000/redis-performance/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: majiayu000 (https://skillmd.com/u/majiayu000)
- Updated: 2026-09-09
- Page: https://skillmd.com/skills/majiayu000/redis-performance

---


# Redis Performance Skill

## Memory Management

```conf
maxmemory 4gb
maxmemory-policy allkeys-lru
maxmemory-samples 10
```

### Eviction Policies
| Policy | Description | Use Case |
|--------|-------------|----------|
| noeviction | Error on full | Critical data |
| allkeys-lru | Evict LRU | General cache |
| volatile-lru | Evict LRU with TTL | Session cache |
| allkeys-lfu | Evict LFU | Frequency-based |

### Memory Analysis
```redis
INFO memory
MEMORY DOCTOR
MEMORY USAGE key
MEMORY STATS
redis-cli --bigkeys
```

## Slow Log

```redis
CONFIG SET slowlog-log-slower-than 10000  # 10ms
CONFIG SET slowlog-max-len 128

SLOWLOG GET 10
SLOWLOG LEN
SLOWLOG RESET
```

### Common Slow Commands
| Command | Fix |
|---------|-----|
| KEYS * | Use SCAN |
| SMEMBERS | Use SSCAN |
| HGETALL | Use HMGET |

## Benchmarking

```bash
# Basic
redis-benchmark -q -n 100000

# With pipelining
redis-benchmark -q -n 100000 -P 16

# Specific commands
redis-benchmark -t set,get -n 100000 -q
```

## Latency Monitoring

```redis
CONFIG SET latency-monitor-threshold 100
LATENCY DOCTOR
LATENCY HISTORY command
```

## Key Metrics

| Metric | Healthy | Warning | Critical |
|--------|---------|---------|----------|
| Memory | <75% | 75-90% | >90% |
| Ops/sec | Baseline | +50% | +100% |
| Latency | <1ms | 1-10ms | >10ms |
| Hit ratio | >95% | 90-95% | <90% |

## Assets
- `performance-config.conf` - Optimized config

## References
- `PERFORMANCE_GUIDE.md` - Tuning guide

---

## Troubleshooting

### High Memory
```redis
INFO memory
redis-cli --bigkeys
```
**Fix:** Set eviction policy, add TTL

### High Latency
```redis
SLOWLOG GET 10
LATENCY DOCTOR
```
**Fix:** Optimize slow commands

---

## Error Codes

| Code | Name | Recovery |
|------|------|----------|
| PERF001 | OOM | Increase maxmemory or evict |
| PERF002 | HIGH_LAT | Check slow log |
| PERF003 | FRAG | MEMORY PURGE or restart |

