Redis Caching & Messaging (Pub/Sub, Streams) · Lección

Análisis del slow log

Use el slow log de Redis para encontrar comandos que bloquean el servidor, interpretar sus entradas y ajustar los umbrales que los registran.

Lección 4 de 413 pasos

Análisis del slow log es una lección gratuita de Redis Caching & Messaging (Pub/Sub, Streams) en CoddyKit. Esta es la lección 4 de 4. Puedes leer la lección completa abajo gratuitamente — luego la practicas en el navegador con un editor de código integrado y un tutor de IA 24/7. Forma parte de la ruta de aprendizaje de Redis Caching & Messaging (Pub/Sub, Streams), y tu progreso se sincroniza en la web y la app de CoddyKit. El curso de Redis Caching & Messaging (Pub/Sub, Streams) incluye 4 lecciones en total.

Partes de esta lección aún no han sido traducidas y se muestran en inglés.

Redis Is Single-Threaded

Command execution in Redis is effectively single-threaded. One slow command blocks every other client. The slow log records commands whose execution time exceeds a threshold, so you can hunt down these blockers.

What It Measures

The slow log times only command execution, not network or I/O wait. So a logged entry means Redis itself spent that long, usually on an expensive operation over many elements.

Configuring the Threshold

slowlog-log-slower-than sets the threshold in microseconds. A value of 10000 logs commands slower than 10ms. Set it to 0 to log everything (for debugging) or -1 to disable.

CONFIG SET slowlog-log-slower-than 10000

Limiting Log Size

slowlog-max-len caps how many entries are retained; older ones are evicted. This keeps memory bounded.

CONFIG SET slowlog-max-len 128

Reading the Log

SLOWLOG GET returns recent entries; pass a count to limit them. Each entry has an ID, timestamp, microsecond duration, the command and arguments, and the client address.

SLOWLOG GET 10

Interpreting an Entry

Look at the command and its duration. A KEYS * or a large SMEMBERS over a million-element set will show big durations, pinpointing the culprit and the calling client.

# 1) id 14
# 2) timestamp 1716900000
# 3) microseconds 23000
# 4) ["KEYS", "*"]

Length and Reset

SLOWLOG LEN gives the current entry count, and SLOWLOG RESET clears the log, handy before reproducing an issue.

SLOWLOG LEN
SLOWLOG RESET

Common Offenders

Frequent slow-log culprits:

  • KEYS on large keyspaces (use SCAN)
  • Big SMEMBERS/HGETALL/LRANGE 0 -1
  • Unbounded SORT
  • Large DEL (use UNLINK)
SCAN 0 MATCH user:* COUNT 100
UNLINK biglist

From Detection to Fix

Once the slow log names a command, fix it: paginate with cursors, model data to avoid huge single keys, or move heavy work off the hot path. Re-check the log to confirm the durations drop.

Continuous Monitoring

Sample the slow log periodically from a monitoring job and alert when slow commands appear, so you catch regressions before users feel them.

redis-cli SLOWLOG GET 5

Threshold Tuning

Start with a moderate threshold (e.g. 10ms) in production. Lower it temporarily when investigating, then restore it, because logging everything adds a tiny per-command cost.

Quick Check

Test your understanding of the slow log.

Recap

You learned to use the slow log: configure slowlog-log-slower-than and slowlog-max-len, read entries with SLOWLOG GET, interpret durations, and fix common offenders like KEYS and huge single-key reads. Monitor it continuously to catch performance regressions early.

Gratis para empezar

Aprende Redis Caching & Messaging (Pub/Sub, Streams) con un tutor de IA — gratis

Escribe y ejecuta código real en tu navegador, obtén ayuda instantánea de un tutor de IA disponible 24/7 y continúa donde lo dejaste en la web o en la aplicación.

Cursos
12
Lecciones
48

Preguntas frecuentes

¿La lección «Análisis del slow log» es gratis?

Sí — el texto completo de «Análisis del slow log» es gratis para leer aquí en la web. Para practicarla de forma interactiva (editor de código integrado y tutor de IA 24/7) y desbloquear el resto del curso de Redis Caching & Messaging (Pub/Sub, Streams), actualiza a CoddyKit PRO. El curso de Redis Caching & Messaging (Pub/Sub, Streams) incluye 4 lecciones en total.

¿Qué aprenderé en «Análisis del slow log»?

Use el slow log de Redis para encontrar comandos que bloquean el servidor, interpretar sus entradas y ajustar los umbrales que los registran. Practicas Redis Caching & Messaging (Pub/Sub, Streams) con código real que ejecutas directamente en el navegador, y un tutor de IA 24/7 responde tus preguntas mientras trabajas en la lección.

¿Necesito experiencia previa para empezar Redis Caching & Messaging (Pub/Sub, Streams)?

No se requiere experiencia previa. Redis Caching & Messaging (Pub/Sub, Streams) en CoddyKit está estructurado para principiantes hasta estudiantes avanzados, así que puedes empezar aquí o desde el inicio y avanzar a tu ritmo. Esta es la lección 4 de 4.

¿Cuánto tiempo toma la lección «Análisis del slow log»?

La mayoría de las lecciones de CoddyKit toman alrededor de 5–10 minutos. Cada una es compacta e interactiva, así que avanzas constantemente y retomas exactamente por donde dejaste en la web y la app.

¿Puedo escribir y ejecutar código en esta lección de Redis Caching & Messaging (Pub/Sub, Streams)?

Sí. Cada lección de Redis Caching & Messaging (Pub/Sub, Streams) incluye un editor de código integrado, así que escribes y ejecutas código real directamente en tu navegador y obtienes retroalimentación instantánea de IA — sin configuración local necesaria.

Todas las lecciones de este curso

  1. Herramientas de monitorización de Redis
  2. Diagnóstico de problemas de rendimiento
  3. Ajuste y optimización del rendimiento
  4. Análisis del slow log
← Volver a Redis Caching & Messaging (Pub/Sub, Streams)