0Pricing
Redis Caching & Messaging (Pub/Sub, Streams) · درس

تحليل السجل البطيء

استخدم السجل البطيء في Redis للعثور على الأوامر التي تحجب الخادم، وتفسير الإدخالات، وضبط الحدود التي تلتقطها

تحليل السجل البطيء درس مجاني في Redis Caching & Messaging (Pub/Sub, Streams) على CoddyKit. هذا هو الدرس 4 من أصل 4. يمكنك قراءة الدرس كاملاً أدناه مجاناً — ثم تمرن عليه مباشرة في المتصفح باستخدام محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7. هذا الدرس جزء من مسار التعلم في Redis Caching & Messaging (Pub/Sub, Streams)، وتقدمك يتزامن عبر الويب وتطبيق CoddyKit. تتضمن دورة Redis Caching & Messaging (Pub/Sub, Streams) 4 دروس في المجموع.

بعض أجزاء هذا الدرس لم تُترجم بعد وتظهر باللغة الإنجليزية.

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.

الأسئلة الشائعة

هل درس «تحليل السجل البطيء» مجاني؟

نعم — نص درس «تحليل السجل البطيء» كامل متاح مجاناً هنا على الويب. لتمرينه بشكل تفاعلي (محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7) وفتح باقي دورة Redis Caching & Messaging (Pub/Sub, Streams)، انتقل إلى CoddyKit PRO. تتضمن دورة Redis Caching & Messaging (Pub/Sub, Streams) 4 دروس في المجموع.

ماذا ستتعلم في «تحليل السجل البطيء»؟

استخدم السجل البطيء في Redis للعثور على الأوامر التي تحجب الخادم، وتفسير الإدخالات، وضبط الحدود التي تلتقطها تتمرن على Redis Caching & Messaging (Pub/Sub, Streams) مع أكواد عملية تشغلها مباشرة في المتصفح، ومدرس ذكاء اصطناعي متاح 24/7 يجيب على أسئلتك أثناء عملك.

هل أحتاج إلى خبرة سابقة لأبدأ Redis Caching & Messaging (Pub/Sub, Streams)؟

لا تُشترط خبرة سابقة. Redis Caching & Messaging (Pub/Sub, Streams) على CoddyKit منظم للمبتدئين حتى المتقدمين، لذا يمكنك البدء من هنا أو من البداية والتقدم بسرعتك الخاصة. هذا هو الدرس 4 من أصل 4.

كم من الوقت يستغرق درس «تحليل السجل البطيء»؟

معظم دروس CoddyKit تستغرق حوالي 5–10 دقائق. كل منها موجز وتفاعلي، لذا تحرز تقدماً مستمراً وتستأنف من حيث توقفت عبر الويب والتطبيق.

هل يمكنني كتابة وتشغيل أكواد في درس Redis Caching & Messaging (Pub/Sub, Streams) هذا؟

نعم. كل درس في Redis Caching & Messaging (Pub/Sub, Streams) يتضمن محرر أكواد مدمج، لذا تكتب وتشغل أكواداً حقيقية مباشرة في متصفحك وتحصل على تعليقات فورية من الذكاء الاصطناعي — بدون إعداد محلي.

جميع الدروس في هذه الدورة

  1. أدوات مراقبة Redis
  2. تشخيص مشكلات الأداء
  3. ضبط الأداء وتحسينه
  4. تحليل السجل البطيء
← العودة إلى Redis Caching & Messaging (Pub/Sub, Streams)