Set maxmemory = 75 % of server RAM and maxmemory-policy = allkeys-lru (or volatile-lru if you rely on TTLs). Watch used_memory_rss / used_memory in INFO — a ratio > 1.5 = fragmentation, run MEMORY PURGE. MEMORY USAGE
Below: details, example, related terms, FAQ.
Free online tool — health checker: instant results, no signup.
# Quick memory audit
$ redis-cli --bigkeys
# top-10 keys by size
$ redis-cli --memkeys --memkeys-samples 100
# Check one key
$ redis-cli MEMORY USAGE sessions:user:1234
(integer) 2048
# Rebalance/defrag
$ redis-cli CONFIG SET activedefrag yes
$ redis-cli MEMORY PURGERedis is an in-memory data structure store, which means managing memory effectively is crucial for optimal performance. Understanding how Redis allocates and manages memory can help you tune your setup for better efficiency.
Redis uses a memory allocator to manage its memory. The default allocator is jemalloc, which is designed for high performance in multi-threaded applications. However, you can also configure Redis to use other allocators like libc or tcmalloc. The choice of allocator can significantly impact memory usage and fragmentation.
To monitor memory usage, use the INFO memory command. This command provides insights into memory fragmentation, total allocated memory, and peak memory usage. Pay attention to the used_memory, used_memory_rss, and mem_fragmentation_ratio metrics. A high fragmentation ratio (greater than 1.5) indicates that Redis is using more memory than necessary, which can be mitigated by using the MEMORY PURGE command to reclaim memory.
Additionally, consider using the maxmemory directive in your configuration to limit Redis memory usage. Setting maxmemory to 75% of your server's total RAM is a common practice. This prevents Redis from consuming all available memory, which could lead to system instability.
Tuning Redis memory involves specific commands and configurations that can help optimize memory usage and performance. Here are some practical commands you can use:
redis.conf file:maxmemory 75% of your_server_RAMmaxmemory-policy allkeys-lruINFO memoryMEMORY USAGE your_key_nameMEMORY PURGEThese commands will help you tune Redis memory effectively. Remember to monitor your server’s performance regularly to adjust configurations as needed.
When tuning Redis memory, several common issues can arise that may affect performance and efficiency. Understanding these issues can help you proactively address them.
1. Memory Fragmentation: This occurs when Redis allocates memory in a way that leads to inefficient use of available space. You can identify fragmentation by checking the mem_fragmentation_ratio in the output of INFO memory. If the ratio exceeds 1.5, consider running MEMORY PURGE to reclaim fragmented memory.
2. Large Keys: Keys that store large hashes or sets without TTLs can consume excessive memory. Use MEMORY USAGE your_key_name to identify memory-heavy keys. Consider restructuring your data model to break down large keys or implementing TTLs where appropriate.
3. Eviction Policy Misconfiguration: Choosing the wrong eviction policy can lead to unexpected behavior. For instance, if you set maxmemory-policy volatile-lru but do not use TTLs, Redis may not evict keys as intended. Ensure that your policy aligns with your data usage patterns.
4. Overcommitting Memory: Setting maxmemory too high can lead to out-of-memory errors. Always set maxmemory to a value that allows for system stability, typically around 75% of total RAM.
By being aware of these common issues, you can better manage Redis memory and optimize your Redis instance for performance.
Health Score is a comprehensive assessment of site technical health across 20+ parameters: SSL, security headers, response speed, SEO technical factors, and availability.
20+ parameters in one number: SSL, headers, speed, SEO technical factors.
Each parameter with explanation — what is checked, what was found, how to fix.
Compare Health Score at different dates — see progress or regression.
Set up automated Health Score checks and get notified when the score drops.
quick pre-release audit
technical baseline score
client site check
header security audit
Health Score check history and real-time site health monitoring.
Sign up freeWhen your workload has a clear hot/cold partition (some keys read forever, others rarely). LFU wins for classic skewed workload.
Fine for pure cache (session, counter). If the data cannot be regenerated, enable AOF everysec.
Redis Cluster — built-in sharding (up to 1000 nodes). For < 100 GB sentinel + application-level sharding is more common.
Free plan — 10 monitors, checks every 5 min, no card required. Upgrade for 1-minute interval and multi-region monitoring.