如何理解linux服务器中的内存使用率和平均负载

如何理解linux服务器中的内存使用率和平均负载,第1张

概述我使用的是具有128GB内存和24个内核的 Linux服务器.我使用top来查看它的使用量.它的输出粘贴在帖子的末尾.这是两个问题: (1)我看到每个正在运行的进程占用很小的内存百分比(%MEM不超过0.2%,大多数只有0.0%),但总内存几乎与第四行输出一样( “Mem:130766620k总计,130161072k使用,605548k免费,919300k缓冲区”)?在所有进程中使用的内存百分比 我使用的是具有128GB内存和24个内核的 Linux服务器.我使用top来查看它的使用量.它的输出粘贴在帖子的末尾.这是两个问题:

(1)我看到每个正在运行的进程占用很小的内存百分比(%MEM不超过0.2%,大多数只有0.0%),但总内存几乎与第四行输出一样( “Mem:130766620k总计,130161072k使用,605548k免费,919300k缓冲区”)?在所有进程中使用的内存百分比总和似乎不太可能实现几乎100%,不是吗?

(2)如何理解第一行的平均负载(“平均负载:14.04,14.02,14.00”)?

感谢致敬!

编辑:

谢谢!

我也非常希望听到一些基于使用的内存百分比的粗略数字,以确定服务器是否负载很重,因为我曾经成为那个在不了解当前负载的情况下使用服务器的人.

交换被视为与内存几乎相同吗?例如,当内存和交换的大小几乎相同时,如果内存几乎耗尽但交换仍然很大程度上是免费的,我可以只查看它,就好像所使用的内存交换百分比仍然不高并运行其他新进程?

你会如何考虑cpu或内存(或内存交换)的使用?如果他们中的任何一个达到太高或两者兼而有之,你会担心吗?

顶部输出:

$top

 top - 12:45:33 up 19 days,23:11,18 users,load average: 14.04,14.00Tasks: 484 total,12 running,472 sleePing,0 stopped,0 zombIEcpu(s): 36.7%us,19.7%sy,0.0%ni,43.6%ID,0.0%wa,0.0%hi,0.0%si,0.0%stMem:  130766620k total,130161072k used,605548k free,919300k buffersSwap: 63111312k total,500556k used,62610756k free,124437752k cached  PID USER      PR  NI  VIRT  RES  SHR S %cpu %MEM    TIME+  COMMAND 6529 sanchez   18  -2 1075m 219m  13m S  100  0.2  13760:23 MATLAB13210 timothy   18  -2 48336  37m 1216 R  100  0.0   3:56.75 absurdity13888 timothy   18  -2 48336  37m 1204 R  100  0.0   2:04.89 absurdity14542 timothy   18  -2 48336  37m 1196 R  100  0.0   1:08.34 absurdity14544 timothy   18  -2  2888 2076  400 R  100  0.0   1:06.14 gatherData 6183 sanchez   18  -2 1133m 195m  13m S  100  0.2  13676:04 MATLAB 6795 sanchez   18  -2 1079m 210m  13m S  100  0.2  13734:26 MATLAB10178 timothy   18  -2 48336  37m 1204 R  100  0.0  11:33.93 absurdity 12438 timothy   18  -2 48336  37m 1216 R  100  0.0   5:38.17 absurdity13661 timothy   18  -2 48336  37m 1216 R  100  0.0   2:44.13 absurdity14098 timothy   18  -2 48336  37m 1204 R  100  0.0   1:58.31 absurdity14335 timothy   18  -2 48336  37m 1196 R  100  0.0   1:08.93 absurdity14765 timothy   18  -2 48336  37m 1196 R   99  0.0   0:32.57 absurdity13445 timothy   18  -2 48336  37m 1216 R   99  0.0   3:01.37 absurdity28990 root      20   0     0    0    0 S    2  0.0  65:50.21 pdflush12141 tim       18  -2 19380 1660 1024 R    1  0.0   0:04.04 top 1240 root      15  -5     0    0    0 S    0  0.0  16:07.11 kjournald 9019 root      20   0  296m 4460 2616 S    0  0.0  82:19.51 kdm_greet    1 root      20   0  4028  728  592 S    0  0.0   0:03.11 init    2 root      15  -5     0    0    0 S    0  0.0   0:00.00 kthreadd    3 root      RT  -5     0    0    0 S    0  0.0   0:01.01 migration/0    4 root      15  -5     0    0    0 S    0  0.0   0:08.13 ksoftirqd/0    5 root      RT  -5     0    0    0 S    0  0.0   0:00.00 watchdog/0    6 root      RT  -5     0    0    0 S    0  0.0  17:27.31 migration/1    7 root      15  -5     0    0    0 S    0  0.0   0:01.21 ksoftirqd/1    8 root      RT  -5     0    0    0 S    0  0.0   0:00.00 watchdog/1    9 root      RT  -5     0    0    0 S    0  0.0  10:02.56 migration/2   10 root      15  -5     0    0    0 S    0  0.0   0:00.34 ksoftirqd/2   11 root      RT  -5     0    0    0 S    0  0.0   0:00.00 watchdog/2   12 root      RT  -5     0    0    0 S    0  0.0   4:29.53 migration/3   13 root      15  -5     0    0    0 S    0  0.0   0:00.34 ksoftirqd/3
解决方法@H_419_27@

(1) I see that each of the running processes occupIEs a very small percentage of memory (%MEM no more than 0.2%,and most just 0.0%),but how the total memory is almost used as in the fourth line of output (“Mem: 130766620k total,919300k buffers”)? The sum of used percentage of memory over all processes seems unlikely to achIEve almost 100%,doesn’t it?

要查看当前使用的内存量,请运行free -m.它将提供如下输出:

             total       used       free     shared    buffers     cachedMem:          2012       1923         88          0         91        515-/+ buffers/cache:       1316        695Swap:         3153        256       2896

顶行’used'(1923)值几乎总是几乎与顶行mem值(2012)匹配.因为linux喜欢使用任何备用内存来缓存磁盘块(515).

用于查看的关键字是缓冲区/缓存行使用值(1316).这是您的应用程序当前使用的空间.为获得最佳性能,此数字应小于您的总(2012)内存.为防止内存不足错误,需要小于总内存(2012)和交换空间(3153).

如果你想快速查看有多少内存空闲,请查看缓冲区/缓存行的空闲值(695).这是总内存(2012) – 实际使用的(1316). (2012 – 1316 = 696,而非695,这只是一个四舍五入的问题)

(2) how to understand the load average on the first line (“load average: 14.04,14.00”)?

这篇关于平均负载的文章使用了一个很好的流量类比,是迄今为止我发现的最好的一个:Understanding Linux CPU Load – when should you be worried?.在你的情况下,正如人们指出的那样:

On multi-processor system,the load is relative to the number of processor cores available. The “100% utilization” mark is 1.00 on a single-core system,2.00,on a dual-core,4.00 on a quad-core,etc.

因此,平均负载为14.00和24个内核,您的服务器远远不会过载.

总结

以上是内存溢出为你收集整理的如何理解linux服务器中的内存使用率和平均负载全部内容,希望文章能够帮你解决如何理解linux服务器中的内存使用率和平均负载所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/yw/1045610.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-24
下一篇 2022-05-24

发表评论

登录后才能评论

评论列表(0条)

保存