我正在尝试将Redis用于生产服务并尝试避免交换,这对性能不利.
我已经知道交换是由swap_tendency触发的,这取决于
swap_tendency = mapped_ratio/2 + swappiness + distress
如何从/ proc / meminfo为我的监视器脚本获取mapped_ratio / distress?
或者任何可以告诉我系统要交换页面的参数?
解决方法:
mapped_ratio
mapped_ratio可以像这样计算:
mapped ratio = (nr mapped * 100) / total memory;
资料来源:https://www.cs.columbia.edu/~smb/classes/s06-4118/l19.pdf
nr_mapped
可以从/ proc / vmstat读取值nr_mapped:
$grep nr_mapped /proc/vmstat
nr_mapped 47640
苦难
根据这篇文章,标题为:Linux Memory – Implementation Notes
“This is a measurement of how much difficulty the VM is having reclaiming pages. Each time the VM tries to reclaim memory, it scans 1/nth of the inactive lists in each zone in an effort to reclaim pages. Each time a pass over the list is made, if the number of inactive clean + free pages in that zone is not over the low water mark, n is decreased by one. Distress is measured as 100 >> n” 07002
在研究大部分文档时,听起来好像“遇险”是内核计数器,但事实并非如此.相反,它是在扫描每个内存区域时使用的值,随着内核扫描内存的页面帧以尝试回收它们,该值逐渐增加.对此的讨论超出了本Q& A的范围,但是如果您对“理解Linux内核”一书中的部分感到好奇,那么“遇险”的值来自于“prev_priority”的值,因为扫描了区域.
参考
> Understanding Memory
> Linux Memory Allocation – PDF
> What Is the Linux Kernel Parameter vm.swappiness?
> 2.6 swapping behavior
> Understanding Virtual Memory In Red Hat Enterprise Linux 4
> Understanding the Linux Kernel 3rd Ed.