overcommit参数需要根据不同服务来进行调整,使内存得到充分利用的同时保证系统的稳定性。比如redis服务器建议把vm.overcommit_memory设置为1.

1、vm.overcommit_ratio 和 vm.overcommit_memory内核参数
参考资料, overcommit-accounting
vm.overcommit_ratio值为0到100,表示允许内核分配的内存超过实际物理内存的百分比。

vm.overcommit_memory值可以是0(default)、1、2,表示overcommit检查和分配策略。
vm.overcommit_memory=0, OVERCOMMIT_GUESS、内核做启发式计算,根据可回收的slab、swap、memory空闲空间决定是够允许分配内存空间。参考内核代码: mmap.c

vm.overcommit_memory=1, OVERCOMMIT_ALWAYS表示不做overcommit检查,总是允许overcommit。

vm.overcommit_memory=2, 如果申请的内存<(total_memory * overcommit_ratio/100 + swap),那么内存申请通过。

2、redis服务器建议设置
vm.overcommit_memory=1 和 vm.overcommit_memory = 10
vm.overcommit_memory=0或者1会导致bgsave不成功,虽然redis是用copy-on-write机制创建子进程。
参考资料: http://redis.io/topics/faq

相关文章:

  • 2021-11-18
  • 2021-07-03
  • 2021-09-24
  • 2021-09-07
  • 2022-12-23
  • 2022-01-02
  • 2021-11-26
  • 2022-12-23
猜你喜欢
  • 2022-02-18
  • 2021-10-23
  • 2021-11-18
  • 2022-12-23
  • 2022-12-23
  • 2021-10-04
  • 2022-12-23
相关资源
相似解决方案