[英]Redis - monitoring maximum memory before inserts fail?
跟蹤和錯誤,通過運行足以測試
while true; do redis-cli lpush mm longstringhere; done;
maxmem - used_memory
結果maxmem - used_memory
<0.1MB,插入失敗:
(錯誤)當使用的內存>'maxmemory'時,不允許OOM命令。
因此,我設置了我通過redis-py客戶端對其進行輪詢,並且當diff小於<1mb閾值時,當然會提高錯誤。 當然,請確保最長命令的user_memory
內存插件也<閾值,否則在插入時會碰到它。
我試圖弄清楚如何計算已用mem的百分比,因此我可以更早地獲得通知方式,例如maxmem的90%,因此此解決方案很好。
信息轉儲:
# Memory
used_memory:3126272
used_memory_human:2.98M
used_memory_rss:5292032
used_memory_rss_human:5.05M
used_memory_peak:4914296
used_memory_peak_human:4.69M
used_memory_peak_perc:63.62%
used_memory_overhead:696654...
此外,maxmem並不是硬性規定,例如,通過將成員添加到現有集中來進一步運行它時。
used_memory:3162584
used_memory_human:3.02M
代碼以獲取0-100%
rmem_info = pipe.info(section='memory')
{'redis_mem_percent': math.ceil(rmem_info['used_memory'] / rmem_info['maxmemory'] *100)}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.