0Pricing
Redis Caching & Messaging (Pub/Sub, Streams) · บทเรียน

เครื่องมือติดตาม Redis

ใช้ `INFO`, `MONITOR` และเครื่องมือภายนอกเพื่อติดตามประสิทธิภาพและตัวชี้วัดสถานะของ Redis

เครื่องมือติดตาม Redis เป็นบทเรียน Redis Caching & Messaging (Pub/Sub, Streams) ฟรีบน CoddyKit นี่คือบทเรียนที่ 1 จากทั้งหมด 4 บทเรียน คุณสามารถอ่านบทเรียนทั้งหมดด้านล่างฟรี — จากนั้นลองปฏิบัติด้วยตัวคุณเองในเบราว์เซอร์พร้อมตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7 บทเรียนนี้เป็นส่วนหนึ่งของเส้นทางการเรียน Redis Caching & Messaging (Pub/Sub, Streams) และความก้าวหน้าของคุณจะซิงค์ข้ามเว็บและแอป CoddyKit คอร์ส Redis Caching & Messaging (Pub/Sub, Streams) มีบทเรียนทั้งหมด 4 บทเรียน

บางส่วนของบทเรียนนี้ยังไม่ได้รับการแปล และแสดงเป็นภาษาอังกฤษ

Why Monitor Redis?

Understanding Redis's health and performance is crucial for any application. Monitoring helps you spot issues before they impact users.

  • Health Check: Ensure Redis is running smoothly.
  • Performance: Identify bottlenecks and optimize operations.
  • Capacity Planning: Predict resource needs as your application grows.

The INFO Command: Basics

The INFO command is your primary tool for gathering information about a Redis server. It provides a comprehensive snapshot of its status, configuration, and statistics.

You can run INFO from the Redis CLI to get a detailed report, organized into various sections.

redis-cli INFO

Exploring INFO Sections

The INFO command output is structured into logical sections, making it easier to find specific data. You can request a specific section for a more focused report.

  • Server: General Redis server information.
  • Clients: Details about connected clients.
  • Memory: Memory usage statistics.
  • Persistence: RDB and AOF persistence details.
  • Stats: General statistics, like connections and commands processed.
  • Replication: Replication status (if configured).
  • CPU: CPU usage statistics.
redis-cli INFO memory

Memory Insights with INFO memory

One of the most critical aspects to monitor is memory usage. The INFO memory command provides detailed statistics about how Redis is consuming RAM.

Key metrics include used_memory_human (readable memory size) and used_memory_peak_human (maximum memory ever consumed).

redis-cli INFO memory

Client Connections with INFO clients

Understanding how many clients are connected and their state can help diagnose connection issues or potential resource exhaustion. Use INFO clients.

Look at connected_clients to see the current number of active connections and blocked_clients for clients waiting on blocking operations.

redis-cli INFO clients

Essential INFO Metrics

While INFO provides a lot of data, some metrics are universally important for quick health checks:

  • uptime_in_seconds: How long Redis has been running.
  • connected_clients: Number of active client connections.
  • used_memory_human: Current memory usage in human-readable format.
  • total_commands_processed: Total commands executed by the server.
  • keyspace_hits / keyspace_misses: Cache hit ratio (important for caching).

Real-time Debugging with MONITOR

The MONITOR command allows you to see all commands processed by the Redis server in real-time. It's a powerful debugging tool, especially for understanding application interactions.

Simply run MONITOR in one CLI window, and you'll see every command executed by other clients.

redis-cli MONITOR

MONITOR Output Example

When you run MONITOR, you'll see a continuous stream of commands, along with their timestamp and client information. Here's what a typical output looks like:

1678886400.123456 [0 127.0.0.1:54321] "SET" "mykey" "myvalue"
1678886400.234567 [0 127.0.0.1:54322] "GET" "anotherkey"
1678886400.345678 [0 127.0.0.1:54321] "LPUSH" "mylist" "item1"

Each line shows the timestamp, database ID, client address, and the command with its arguments.

MONITOR: When Not to Use It

While useful for debugging, MONITOR has significant overhead. It sends every command to the client running MONITOR, which can impact server performance, especially under high load.

Avoid using MONITOR in production environments for continuous monitoring. It's best reserved for short-term, targeted debugging sessions.

Quick Check on Monitoring

Which Redis command is generally not recommended for continuous monitoring in a high-traffic production environment due to its performance overhead?

Monitoring Redis: Summary

You've learned about essential Redis monitoring tools!

  • The INFO command provides a detailed snapshot of your Redis instance's health and statistics, organized into sections.
  • The MONITOR command offers a real-time stream of all commands executed, useful for debugging but not for continuous production use due to overhead.
  • For production monitoring, consider integrating Redis with external tools like Prometheus, Grafana, or RedisInsight.

These tools are vital for ensuring your Redis deployment runs efficiently and reliably.

คำถามที่พบบ่อย

บทเรียน “เครื่องมือติดตาม Redis” ฟรีหรือไม่

ใช่ — ข้อความเต็มของ “เครื่องมือติดตาม Redis” ฟรีให้อ่านที่นี่บนเว็บ เพื่อปฏิบัติแบบโต้ตอบ (ตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7) และปลดล็อคส่วนที่เหลือของคอร์ส Redis Caching & Messaging (Pub/Sub, Streams) ให้อัปเกรดเป็น CoddyKit PRO คอร์ส Redis Caching & Messaging (Pub/Sub, Streams) มีบทเรียนทั้งหมด 4 บทเรียน

คุณจะเรียนรู้อะไรในบทเรียน “เครื่องมือติดตาม Redis”

ใช้ `INFO`, `MONITOR` และเครื่องมือภายนอกเพื่อติดตามประสิทธิภาพและตัวชี้วัดสถานะของ Redis คุณปฏิบัติ Redis Caching & Messaging (Pub/Sub, Streams) ด้วยโค้ดที่ใช้งานได้จริงที่คุณเรียกใช้โดยตรงในเบราว์เซอร์ และติวเตอร์ AI ตลอด 24/7 ตอบคำถามของคุณขณะที่คุณไปผ่านบทเรียน

คุณต้องมีประสบการณ์ก่อนที่จะเริ่มเรียน Redis Caching & Messaging (Pub/Sub, Streams) หรือไม่

ไม่จำเป็นต้องมีประสบการณ์มาก่อน Redis Caching & Messaging (Pub/Sub, Streams) บน CoddyKit ออกแบบมาสำหรับผู้เริ่มต้นไปจนถึงผู้เรียนขั้นสูง คุณสามารถเริ่มต้นที่นี่หรือเริ่มจากตัวแรกและเรียนด้วยความเร็วของคุณเอง นี่คือบทเรียนที่ 1 จากทั้งหมด 4 บทเรียน

บทเรียน “เครื่องมือติดตาม Redis” ใช้เวลานานแค่ไหน

บทเรียน CoddyKit ส่วนใหญ่ใช้เวลาประมาณ 5–10 นาที แต่ละบทเรียนจึงสั้นและเป็นแบบโต้ตอบ คุณสามารถก้าวหน้าอย่างต่อเนื่องและกลับมาเรียนต่อจากตรงที่เพิ่งหยุดบนเว็บและแอปได้เลย

ฉันเขียนและรันโค้ดในบทเรียน Redis Caching & Messaging (Pub/Sub, Streams) นี้ได้ไหม

ได้ บทเรียน Redis Caching & Messaging (Pub/Sub, Streams) ทุกบทมีตัวแก้ไขโค้ดในตัว คุณจึงเขียนและรันโค้ดจริงได้เลยในเบราว์เซอร์ และได้รับข้อเสนอแนะจาก AI ในทันที — ไม่ต้องติดตั้งในเครื่องของคุณ

บทเรียนทั้งหมดในหลักสูตรนี้

  1. เครื่องมือติดตาม Redis
  2. การวินิจฉัยปัญหาด้านประสิทธิภาพ
  3. การปรับแต่งและเพิ่มประสิทธิภาพ
  4. การวิเคราะห์บันทึกการทำงานช้า
← กลับไปที่ Redis Caching & Messaging (Pub/Sub, Streams)