Mastering Redis INFO: Monitoring, Memory Management, and Eviction Strategies
This guide explains how to interpret Redis INFO output, monitor client connections, memory usage, persistence stats, replication CPU metrics, configure eviction policies, understand the LRU algorithm, and perform performance analysis to keep your Redis instance healthy and efficient.
Clients
connected_clients:2 – Redis allows up to 10,000 client connections by default; exceeding 5,000 may affect performance. Use the maxclients setting to limit connections, typically set to 110%–150% of the expected peak.
Memory
Memory metrics include used_memory (actual data memory), used_memory_rss (memory allocated by the OS, including fragmentation), and used_memory_peak. A mem_fragmentation_ratio above 1.5 indicates significant fragmentation, while a ratio below 1 suggests memory swapping and potential latency.
Persistence / Stats
Key statistics: total connections received, total commands processed, instantaneous ops per second, rejected connections, sync status, expired and evicted keys, keyspace hits/misses, pub/sub channels, and latest fork duration.
Replication / CPU
CPU usage is cumulative; values reset after a Redis restart. Metrics include used_cpu_sys, used_cpu_user, used_cpu_sys_children, and used_cpu_user_children.
Commandstats, Cluster, Keyspace
These sections provide detailed command execution counts, cluster state, and keyspace distribution.
Eviction Policies
Configure memory limits with maxmemory (e.g., CONFIG SET maxmemory 100mb) and choose an eviction policy via maxmemory-policy. The six policies are:
volatile-lru – evict least‑recently‑used keys with an expiration.
volatile-random – evict random keys with an expiration.
volatile-ttl – evict keys closest to expiration.
allkeys-lru – evict least‑recently‑used keys regardless of expiration.
allkeys-random – evict random keys.
noeviction – reject writes when memory limit is reached.
When unsure, allkeys-lru is a safe default, especially for power‑law data distributions.
LRU
Each Redis object has an lru field recording the last access time. The OBJECT IDLETIME command reports idle time without modifying the lru. Redis implements an approximate LRU algorithm: it samples maxmemory-samples keys and evicts the least recently used among them. Increasing the sample size improves accuracy but adds overhead.
Performance Analysis
Use redis-cli --latency -h 127.0.0.1 -p 6379 to measure latency in milliseconds. Track total_commands_processed over time; a rising trend when clients notice slow responses indicates performance degradation. Common causes include long command queues, slow commands blocking the server, and large‑set operations. Mitigation strategies: use multi‑argument commands, pipeline commands, and avoid slow operations on large collections.
Redis Configuration
Example redis.conf entries:
slaveof 127.0.0.1 6380
requirepass "hello world"Start Redis with command‑line parameters, e.g., ./redis-server --port 6380 --slaveof 127.0.0.1 6379. The CONFIG REWRITE command rewrites the configuration file with runtime changes.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
MaGe Linux Operations
Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
