スローログを分析する
Redisのスローログを使ってサーバーをブロックするコマンドを見つけ、エントリを解釈し、それらを記録するしきい値を調整します。
「スローログを分析する」はCoddyKit上の無料Redis Caching & Messaging (Pub/Sub, Streams)レッスンです。 これはレッスン4/4です。 下記で完全なレッスンを無料で読むことができます。その後、ブラウザ内の組み込みコードエディタと24時間対応のAIチューターでハンズオン演習できます。 これは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 10000Limiting Log Size
slowlog-max-len caps how many entries are retained; older ones are evicted. This keeps memory bounded.
CONFIG SET slowlog-max-len 128Reading 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 10Interpreting 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 RESETCommon Offenders
Frequent slow-log culprits:
KEYSon large keyspaces (useSCAN)- Big
SMEMBERS/HGETALL/LRANGE 0 -1 - Unbounded
SORT - Large
DEL(useUNLINK)
SCAN 0 MATCH user:* COUNT 100
UNLINK biglistFrom 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 5Threshold 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.
AI チューターと学ぶ Redis Caching & Messaging (Pub/Sub, Streams) — 無料
ブラウザでリアルコードを書いて実行し、24/7 の AI チューターから瞬時にサポートを受け、ウェブまたはアプリで続きから学習できます。
- コース
- 12
- レッスン
- 48
よくある質問
「スローログを分析する」レッスンは無料ですか?
はい。「スローログを分析する」の完全なテキストはこのウェブで無料で読めます。インタラクティブに演習し(組み込みコードエディタと24時間対応のAIチューター)、Redis Caching & Messaging (Pub/Sub, Streams)コースの残りをアンロックするには、CoddyKit PROにアップグレードしてください。 Redis Caching & Messaging (Pub/Sub, Streams)コースには全4レッスンが含まれています。
「スローログを分析する」で何を学びますか?
Redisのスローログを使ってサーバーをブロックするコマンドを見つけ、エントリを解釈し、それらを記録するしきい値を調整します。 ブラウザで直接実行するハンズオンコードでRedis Caching & Messaging (Pub/Sub, Streams)を演習し、24時間対応のAIチューターがレッスンを進める中での質問に答えます。
Redis Caching & Messaging (Pub/Sub, Streams)を始めるのに経験は必要ですか?
事前経験は必要ありません。CoddyKitのRedis Caching & Messaging (Pub/Sub, Streams)は初級者から上級者向けに構成されているため、ここから始めるか最初から始めて、自分のペースで進むことができます。 これはレッスン4/4です。
「スローログを分析する」レッスンにはどのくらい時間がかかりますか?
ほとんどのCoddyKitレッスンは約5~10分かかります。各レッスンはコンパクトでインタラクティブなので、着実に進歩し、ウェブとアプリ全体で正確に前回の場所から再開できます。
このRedis Caching & Messaging (Pub/Sub, Streams)レッスンでコードを書いて実行できますか?
はい。すべてのRedis Caching & Messaging (Pub/Sub, Streams)レッスンに組み込みコードエディタが含まれているため、ブラウザでリアルコードを書いて実行し、即座のAIフィードバックを取得できます。ローカル設定は不要です。
このコースのすべてのレッスン
- Redis 監視ツール
- パフォーマンス問題の診断
- パフォーマンスチューニングと最適化
- スローログを分析する