background

XXX failed: OOM command not allowed when used Memory > ‘maxMemory ‘. This error message is displayed on the REDis server in the SIT environment

Troubleshooting steps

  1. Log in to the Redis client and run./redis-cli -h IP -p port -a passwd or RedisDesktopManager
  2. Enter the info memory command to view memory information
Connected.
xx.x.xx.x@sit:0>info memory
"# Memory used_memory:915574200 # Memory allocated by the Redis allocator Used_memory_human: 873.16m used_memory_rss:1051254784 Returns the total amount of memory Redis has allocated. Used_memory_rss_human: 1002.55m used_memory_peak:4297736416 #Redis memory consumption peak in bytes Used_memory_peak_human: 4.00g USed_memorY_peak_perc :21.30% # Percentage of used memory to peak memory (used_memory/used_memory_peak) *100% Used_memory_overhead :43275440 # Redis the memory overhead required to maintain the internal mechanism of the data set, including all client output buffers, query buffers, AOF rewrite buffers and master/slave replication backlogs Used_memory_startup :35352360 # Redis memory used to dataset:872298760 # Data overhead (used_memory-used_memory_overhead) Used_memory_dataset_perc :99.10% # Percentage of memory size occupied by data,(USed_memory_dataset/(used_memory-used_memory_startup))*100% Total_system_memory :403513290752 total_system_memory_human: 375.80g used_memory_lua:47104 # Memory occupied by the Lua engine (byte) USed_memorY_luA_human :46.00K MAXMemory :4294967296 # Specifies the maximum available memory (byte) set in the configuration. The default value is 0 and there is no limit Maxmemory_human: 4.00g MAXmemory_policy :noeviction # Mem_fragmentation_ratio :1.15 # The fragmentation rate (used_memory_rss/used_memory) is normal (1,1.6). If the value is greater than the ratio, memory fragmentation is severe. Mem_allocator :jemalloc-4.0.3 # memory allocator active_defrag_running:0 # Active defragmentation is active (0 is not,1 is running) lazyFree_PENDing_OBJECTS :0 # 0- There are no pending objects with deferred releaseCopy the code

See the article for details on the meaning of each info memory metric

3. Main indicators:

Used_memory_peak_human memory peak, maxMemory maximum memory is basically flat, USed_memory_dataset_perc reached 99.10%, key did not free memory,

The main reason is maxMemory_policy memory exclusion policy for Noeviction, which will never expire, return errors, and never discard keys

To improve the

Redis’ MaxMemory_policy memory elimination policy:

Volatile – lRU: LRU only for keys with expiration time (default)

2, allkeys-lRU: delete the key of the LRU algorithm

Volatile -random: deletes expired keys randomly

4. Allkeys-random: delete randomly

5. Volatile – TTL: delete expiring packets

Noeviction: never expire, returns errors

Improvement methods include:

A. Set maxmemory_policy to allkeys-lRU: delete keys of the LRU algorithm and delete keys that have not been used recently. B. Consider expanding redis and maintaining key deletion in code based on business conditions, or automatically deleting expired keys through scheduled tasksCopy the code