Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to parse redis memory information

2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

How to parse the redis memory information, I believe that many inexperienced people are at a loss about this. Therefore, this paper summarizes the causes and solutions of the problem. Through this article, I hope you can solve this problem.

Used_memory: the total amount of memory allocated by the Redis allocator, including the internal overhead of the redis process and the memory occupied by the data, in byte

Used_memory_rss: the amount of memory requested from the operating system. Consistent with the output of top, ps, and other commands.

Peak memory consumption of used_memory_peak:redis (in bytes)

Used_memory_peak_perc: percentage of memory used to reach peak memory, i.e. (used_memory/ used_memory_peak) * 100%

The memory overhead required by used_memory_overhead:Redis to maintain the internal mechanism of the dataset, including all client output buffers, query buffers, AOF rewrite buffers, and master-slave replicated backlog.

Memory consumed when the used_memory_startup:Redis server starts

Used_memory_dataset: the amount of memory occupied by data, that is, used_memory-sed_memory_overhead

Used_memory_dataset_perc: percentage of memory occupied by data, 100% * (used_memory_dataset/ (used_memory-used_memory_startup))

Total_system_memory: entire system memory

Memory consumed by used_memory_lua:Lua script storage

Maximum memory configuration of maxmemory:Redis instance

Maxmemory_policy: elimination strategy when maxmemory is reached

Mem_fragmentation_ratio: fragmentation rate, used_memory_rss/ used_memory

Mem_allocator: memory allocator

Active_defrag_running: indicates that no active defrag task is running, and 1 indicates that there is an active defrag task running (defrag: indicates memory defragmentation)

Lazyfree_pending_objects:0 indicates that there is no pending object with delayed release

Redis uses a maximum value that exceeds the setting

What happens if the use of Redis exceeds the maximum value set? Let's change the configuration above and deliberately set the maximum value to 1 byte.

# output buffers (but this is not needed if the policy is' noeviction'). # # maxmemory maxmemory 1

Open the page in debug mode and indicate an error: OOM command not allowed when used memory > 'maxmemory'.

The option of maxmemory is set, and the use of redis memory reaches the upper limit. You can delete part of the key and free up space by setting the LRU algorithm. By default, it is based on the expiration time. If the expiration time is not added in the set, it will cause the data to be full of maxmemory.

If the maxmemory is not set or the memory is not limited on a 64-bit system, a 32-bit system will use up to 3GB memory.

LRU is the least used algorithm for Least Recently Used recently.

Volatile-lru-> is deleted based on the expiration time generated by the LRU algorithm.

Allkeys-lru-> Delete any key according to the LRU algorithm.

Volatile-random-> randomly delete key according to the expiration setting.

Allkeys- > random-> delete randomly without difference.

Volatile-ttl-> delete based on the most recent expiration time (supplemented by TTL)

Noeviction-> No one deletes it, and an error is returned during the write operation.

If maxmemory is set, it is generally necessary to set the expiration policy. The configuration file that opens Redis is described as follows. Redis has six expiration policies:

# volatile-lru-> remove the key with an expire set using an LRU algorithm# allkeys-lru-> remove any key accordingly to the LRU algorithm# volatile-random-> remove a random key with an expire set# allkeys-random-> remove a random key, any key# volatile-ttl-> remove the key with the nearest expire time (minor TTL) # noeviction-> don't expire at all, just return an error on write operations

Then open the configuration file, add the following line, and use the expiration policy of volatile-lru:

Maxmemory-policy volatile-lru

Save the file to exit and restart the redis service.

After reading the above, have you mastered how to parse the redis memory information? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report