谁在使用我的生产服务器(apache + mysql + Rails)上的所有内存?
我正在运行一个 EC2 小型实例作为我的生产服务器。它有1.7G内存。我注意到它几乎使用了所有内存。然而,当我检查顶部输出时,看起来实际只使用了 30%。我是否误读了顶部输出?
这是顶部输出(按 %MEM 排序)
top - 21:33:15 up 141 days, 9:39, 2 users, load average: 0.00, 0.00, 0.00 Tasks: 81 total, 2 running, 79 sleeping, 0 stopped, 0 zombie Cpu(s): 0.0%us, 0.0%sy, 0.0%ni,100.0%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st Mem: 1747660k total, 1733580k used, 14080k free, 224144k buffers Swap: 917496k total, 132k used, 917364k free, 1144808k cached PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 11664 mysql 15 0 794m 83m 5020 S 0.0 4.9 0:17.34 mysqld 12845 nobody 25 0 52416 38m 3200 S 0.0 2.3 0:02.10 ruby1.8 12847 nobody 16 0 52704 38m 2068 S 0.0 2.2 0:02.08 ruby1.8 12023 www-data 15 0 37692 10m 4164 S 0.0 0.6 0:01.28 apache2 11979 www-data 15 0 37660 10m 4172 S 0.0 0.6 0:01.24 apache2 12020 www-data 15 0 37708 10m 4120 S 0.0 0.6 0:01.17 apache2 12263 www-data 15 0 37708 10m 4176 S 0.0 0.6 0:00.83 apache2 11989 www-data 15 0 37720 10m 4024 S 0.0 0.6 0:01.28 apache2 12014 www-data 15 0 37468 10m 4172 S 0.0 0.6 0:01.17 apache2 12021 www-data 15 0 37652 10m 3992 S 0.0 0.6 0:01.25 apache2 12054 www-data 15 0 37480 10m 4176 S 0.0 0.6 0:01.33 apache2 11990 www-data 15 0 37448 10m 4188 S 0.0 0.6 0:01.16 apache2 12024 www-data 16 0 37416 10m 4172 S 0.0 0.6 0:01.00 apache2 11991 www-data 15 0 37432 10m 4148 S 0.0 0.6 0:01.24 apache2 11984 www-data 15 0 37444 9.8m 3972 S 0.0 0.6 0:01.33 apache2 11985 www-data 15 0 37444 9.8m 3948 S 0.0 0.6 0:01.18 apache2 11982 www-data 15 0 37408 9.8m 3968 S 0.0 0.6 0:01.12 apache2 12013 www-data 17 0 37432 9.8m 4152 S 0.0 0.6 0:01.19 apache2 12052 www-data 15 0 37176 9.8m 4180 S 0.0 0.6 0:01.29 apache2 11981 www-data 15 0 37172 9.8m 4168 S 0.0 0.6 0:01.40 apache2 12395 www-data 15 0 37420 9988 3972 S 0.0 0.6 0:00.72 apache2 12015 www-data 15 0 37412 9972 3900 S 0.0 0.6 0:01.31 apache2 11987 www-data 15 0 37160 9956 4136 S 0.0 0.6 0:01.22 apache2 12022 www-data 15 0 37140 9900 4140 S 0.0 0.6 0:01.20 apache2 12051 www-data 15 0 37216 9848 3976 S 0.0 0.6 0:01.31 apache2 11978 www-data 18 0 36948 9784 4180 S 0.0 0.6 0:01.08 apache2 11975 www-data 15 0 37140 9772 3972 S 0.0 0.6 0:01.49 apache2 12019 www-data 15 0 37148 9752 3944 S 0.0 0.6 0:01.08 apache2 11970 www-data 15 0 36920 9736 4160 S 0.0 0.6 0:01.25 apache2 11974 www-data 15 0 36848 9656 4148 S 0.0 0.6 0:01.53 apache2 11973 www-data 15 0 36924 9552 3972 S 0.0 0.5 0:01.19 apache2 28622 root 18 0 35232 9232 5592 S 0.0 0.5 0:00.30 apache2 11969 www-data 15 0 36340 9132 4136 S 0.0 0.5 0:01.51 apache2 12018 www-data 19 0 36332 9124 4136 S 0.0 0.5 0:01.32 apache2 11972 www-data 15 0 36320 8968 3988 S 0.0 0.5 0:01.33 apache2 12012 www-data 15 0 35796 8600 4144 S 0.0 0.5 0:01.11 apache2 11965 root 15 0 17356 7552 1644 S 0.0 0.4 0:00.13 ruby1.8 12848 root 15 0 8384 2744 2164 R 0.0 0.2 0:00.12 sshd 12762 root 15 0 8384 2724 2164 S 0.0 0.2 0:00.01 sshd 11302 postfix 18 0 6184 2576 1880 S 0.0 0.1 0:00.02 tlsmgr 11964 root 16 0 8188 2248 1492 S 0.0 0.1 0:00.06 ApplicationPool 23997 postfix 22 0 5856 1852 1488 S 0.0 0.1 0:00.22 qmgr 12850 root 15 0 4408 1848 1436 S 0.0 0.1 0:00.00 bash 12764 root 25 0 4396 1800 1400 S 0.0 0.1 0:00.00 bash 23996 root 15 0 5804 1780 1428 S 0.0 0.1 0:01.01 master 13036 postfix 17 0 5812 1684 1356 S 0.0 0.1 0:00.00 pickup 1051 klog 18 0 2884 1676 436 S 0.0 0.1 0:00.04 klogd 13035 root 15 0 2468 1164 916 R 0.0 0.1 0:00.01 top 5841 nobody 15 0 2652 1120 684 S 0.0 0.1 0:00.50 memcached 11509 root 15 0 5456 1068 676 S 0.0 0.1 0:00.00 sshd 1163 root 18 0 3560 1060 872 S 0.0 0.1 0:01.46 cron 1 root 18 0 2032 840 580 S 0.0 0.0 0:04.20 init 4070 syslog 18 0 2056 732 568 S 0.0 0.0 7:25.48 syslogd 908 root 16 -2 2292 656 528 S 0.0 0.0 0:00.06 dhclient3
I am running a EC2 small instance as my production server. It has 1.7G memory. I noticed it uses almost all memory. However when I check top output, it looks like that only 30% is actually used. Did I misread the top output?
Here is the top output (sorted by %MEM)
top - 21:33:15 up 141 days, 9:39, 2 users, load average: 0.00, 0.00, 0.00 Tasks: 81 total, 2 running, 79 sleeping, 0 stopped, 0 zombie Cpu(s): 0.0%us, 0.0%sy, 0.0%ni,100.0%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st Mem: 1747660k total, 1733580k used, 14080k free, 224144k buffers Swap: 917496k total, 132k used, 917364k free, 1144808k cached PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 11664 mysql 15 0 794m 83m 5020 S 0.0 4.9 0:17.34 mysqld 12845 nobody 25 0 52416 38m 3200 S 0.0 2.3 0:02.10 ruby1.8 12847 nobody 16 0 52704 38m 2068 S 0.0 2.2 0:02.08 ruby1.8 12023 www-data 15 0 37692 10m 4164 S 0.0 0.6 0:01.28 apache2 11979 www-data 15 0 37660 10m 4172 S 0.0 0.6 0:01.24 apache2 12020 www-data 15 0 37708 10m 4120 S 0.0 0.6 0:01.17 apache2 12263 www-data 15 0 37708 10m 4176 S 0.0 0.6 0:00.83 apache2 11989 www-data 15 0 37720 10m 4024 S 0.0 0.6 0:01.28 apache2 12014 www-data 15 0 37468 10m 4172 S 0.0 0.6 0:01.17 apache2 12021 www-data 15 0 37652 10m 3992 S 0.0 0.6 0:01.25 apache2 12054 www-data 15 0 37480 10m 4176 S 0.0 0.6 0:01.33 apache2 11990 www-data 15 0 37448 10m 4188 S 0.0 0.6 0:01.16 apache2 12024 www-data 16 0 37416 10m 4172 S 0.0 0.6 0:01.00 apache2 11991 www-data 15 0 37432 10m 4148 S 0.0 0.6 0:01.24 apache2 11984 www-data 15 0 37444 9.8m 3972 S 0.0 0.6 0:01.33 apache2 11985 www-data 15 0 37444 9.8m 3948 S 0.0 0.6 0:01.18 apache2 11982 www-data 15 0 37408 9.8m 3968 S 0.0 0.6 0:01.12 apache2 12013 www-data 17 0 37432 9.8m 4152 S 0.0 0.6 0:01.19 apache2 12052 www-data 15 0 37176 9.8m 4180 S 0.0 0.6 0:01.29 apache2 11981 www-data 15 0 37172 9.8m 4168 S 0.0 0.6 0:01.40 apache2 12395 www-data 15 0 37420 9988 3972 S 0.0 0.6 0:00.72 apache2 12015 www-data 15 0 37412 9972 3900 S 0.0 0.6 0:01.31 apache2 11987 www-data 15 0 37160 9956 4136 S 0.0 0.6 0:01.22 apache2 12022 www-data 15 0 37140 9900 4140 S 0.0 0.6 0:01.20 apache2 12051 www-data 15 0 37216 9848 3976 S 0.0 0.6 0:01.31 apache2 11978 www-data 18 0 36948 9784 4180 S 0.0 0.6 0:01.08 apache2 11975 www-data 15 0 37140 9772 3972 S 0.0 0.6 0:01.49 apache2 12019 www-data 15 0 37148 9752 3944 S 0.0 0.6 0:01.08 apache2 11970 www-data 15 0 36920 9736 4160 S 0.0 0.6 0:01.25 apache2 11974 www-data 15 0 36848 9656 4148 S 0.0 0.6 0:01.53 apache2 11973 www-data 15 0 36924 9552 3972 S 0.0 0.5 0:01.19 apache2 28622 root 18 0 35232 9232 5592 S 0.0 0.5 0:00.30 apache2 11969 www-data 15 0 36340 9132 4136 S 0.0 0.5 0:01.51 apache2 12018 www-data 19 0 36332 9124 4136 S 0.0 0.5 0:01.32 apache2 11972 www-data 15 0 36320 8968 3988 S 0.0 0.5 0:01.33 apache2 12012 www-data 15 0 35796 8600 4144 S 0.0 0.5 0:01.11 apache2 11965 root 15 0 17356 7552 1644 S 0.0 0.4 0:00.13 ruby1.8 12848 root 15 0 8384 2744 2164 R 0.0 0.2 0:00.12 sshd 12762 root 15 0 8384 2724 2164 S 0.0 0.2 0:00.01 sshd 11302 postfix 18 0 6184 2576 1880 S 0.0 0.1 0:00.02 tlsmgr 11964 root 16 0 8188 2248 1492 S 0.0 0.1 0:00.06 ApplicationPool 23997 postfix 22 0 5856 1852 1488 S 0.0 0.1 0:00.22 qmgr 12850 root 15 0 4408 1848 1436 S 0.0 0.1 0:00.00 bash 12764 root 25 0 4396 1800 1400 S 0.0 0.1 0:00.00 bash 23996 root 15 0 5804 1780 1428 S 0.0 0.1 0:01.01 master 13036 postfix 17 0 5812 1684 1356 S 0.0 0.1 0:00.00 pickup 1051 klog 18 0 2884 1676 436 S 0.0 0.1 0:00.04 klogd 13035 root 15 0 2468 1164 916 R 0.0 0.1 0:00.01 top 5841 nobody 15 0 2652 1120 684 S 0.0 0.1 0:00.50 memcached 11509 root 15 0 5456 1068 676 S 0.0 0.1 0:00.00 sshd 1163 root 18 0 3560 1060 872 S 0.0 0.1 0:01.46 cron 1 root 18 0 2032 840 580 S 0.0 0.0 0:04.20 init 4070 syslog 18 0 2056 732 568 S 0.0 0.0 7:25.48 syslogd 908 root 16 -2 2292 656 528 S 0.0 0.0 0:00.06 dhclient3
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
Mem:总共 1747660k,已用 1733580k,空闲 14080k,224144k 缓冲区
比较总数和已用:-)
Mem: 1747660k total, 1733580k used, 14080k free, 224144k buffers
compare the total and used :-)
它用于文件缓冲。这没有什么问题,因为良好的内存管理应该始终使用系统中的所有可用内存。我不记得了,但我认为
1144808k cached
是你找不到的内存。您可以尝试编写保留约 1 GB 内存的简单应用程序,然后释放它并退出。那么您可能应该将这 1 GB 计为可用内存,因为文件缓冲区已被删除。
It is used for file buffering. It is nothing wrong since good memory managment should always use all availble memory in system. I don't remember but I think that
1144808k cached
is the memory you can't find.You can try writing simple application that reserves about 1 GB of memory and release it and quit. Then probably you should have this 1 GB counted as free memory since file buffers was removed.
“已使用”计数包括文件系统缓存和内核缓冲区。当应用程序需要更多堆时,可以释放缓存内存。你说得对,实际上只使用了大约 30%,因为其中 65% 是缓存,12% 是缓冲区。
当应用程序尝试分配更多内存时,内核将释放缓存的内存,这是正常行为,我认为您的内存使用没有问题。
当您使用大量交换空间,并且您的“缓存”计数非常低时,那么您就会遇到问题。
这里有一些额外的有用信息(适用于任何 Linux 发行版)-
http://forums.gentoo.org/viewtopic.php?t=175419
The 'used' count includes filesystem cache and kernel buffers. The cached memory can be free'd when an application requires more heap. You are right to say that only about 30% is actually used, since 65% of that is cache, and 12% is buffers.
The kernel will release the cached memory when an application attempts to allocate more memory, this is normal behavior and I see no problem with your memory usage.
When you use significant amounts of swap, and your 'cached' count is very low - then you have a problem.
Some additional helpful information here (applicable to any Linux distro) -
http://forums.gentoo.org/viewtopic.php?t=175419