redis最大储存512m_选择Redis最大内存大小和BGSAVE内存使用情况

在写密集型应用中,拥有8GB RAM的服务器,在考虑其他进程占用约1GB内存的情况下,Redis进程的最大内存使用不应超过7GB。由于BGSAVE事件可能导致内存使用翻倍,Redis的maxmemory设置应不超过(8GB - 1GB) / 2 = 3.5GB。建议实际设置为3GB,预留2GB给系统,或在持久化主服务器上保留40%的最大内存。对于高写入量的应用,推荐使用第二个服务器进行保存操作以保持响应速度。
摘要由CSDN通过智能技术生成

I am trying to find out what a safe setting for 'maxmemory' would be in the following situation:

write-heavy application

8GB RAM

let's assume other processes take up about 1GB

this means that the redis process' memory usage may never exceed 7GB

memory usage doubles on every BGSAVE event, because:

In the redis docs the following is said about the memory usage increasing on BGSAVE events:

If you are using Redis in a very write-heavy application, while saving an RDB file on disk or rewriting the AOF log Redis may use up to 2 times the memory normally used.

the maxmemory limit is roughly compared to 'used_memory' from redis-cli INFO (as is explained here) and does not take other memory used by redis into account

Am I correct that this means that the maxmemory setting should, in this situation, be set no higher than (8GB - 1GB) / 2 = 3.5GB?

If so, I will create a pull request for the redis docs to reflect this more clearly.

解决方案

I would recommend in this case a limit of 3GB. Yes, the docs are pretty much correct and running a bgsave will double for a short term the memory requirements. However, I prefer to reserve 2GB of memory for the system, or at a maximum for a persisting master 40% of maximum memory.

You indicate you have a very write heavy application. In this case I would highly recommend a second server do the save operations. I've found during high writes and a bgsave the response time to the client(s) can get high. It isn't Redis per se causing it, but the response of the server itself. This is especially true for virtual machines. Under this setup you would use the second server to slave from the primary and save to disk while the first remains responsive.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值