linux – 交换内存耗尽服务器甚至站点都有小访问者

前端之家收集整理的这篇文章主要介绍了linux – 交换内存耗尽服务器甚至站点都有小访问者前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我在32位VPS主机上运行CentOs 6.5.它只运行PHP-fpm,Nginxmysql.

我的网站每天平均有20个访问者,但我最近收到了来自我的主机提供商的此消息.

This is an automated notification to inform you that your VPS named ‘name.here’ has been severely slowed down the past hour because of swapping.

Swapping is the result of a lack of memory. If the memory of a VPS is completely filled,parts of memory are written to hard disk to prevent the server from crashing. Because hard disks are many times slower than memory your server performance is severely reduced.

我想弄清楚这一点.内容较少的网站如何获得20次访问会消耗那么多内存?

我不确定这是来自PHP,centos ……还是其他.但我在这里有一些输出,有人可能会确定问题的核心.

[root@site.name~]# free -m
             total       used       free     shared    buffers     cached
Mem:           498        489          9          0          1         19
-/+ buffers/cache:        469         29
Swap:         1022        180        842
top - 18:33:36 up 65 days,1 min,1 user,load average: 0.00,0.02,0.00
Tasks: 109 total,1 running,108 sleeping,0 stopped,0 zombie
cpu(s):  1.0%us,0.3%sy,0.0%ni,98.3%id,0.3%wa,0.0%hi,0.0%si,0.0%st
Mem:    510868k total,503092k used,7776k free,1904k buffers
Swap:  1047544k total,185096k used,862448k free,20956k cached

  PID USER      PR  NI  VIRT  RES  SHR S %cpu %MEM    TIME+  COMMAND
 7435 MysqL     20   0  352m 7752 2852 S  1.0  1.5  56:23.52 MysqLd
17806 Nginx     20   0 50088  12m 2640 S  0.7  2.5  18:13.65 PHP-fpm
  984 root      20   0  8940  372  272 S  0.3  0.1   0:29.68 sshd
 3148 root      20   0  2692 1128  880 R  0.3  0.2   0:00.15 top
    1 root      20   0  2900  416  292 S  0.0  0.1   0:07.29 init

这可能是什么问题?它有什么问题吗?

UPDATE

@Michael Hampton输出顶部>转移M.

top - 14:34:29 up 66 days,20:02,2 users,0.00,0.00
Tasks: 110 total,109 sleeping,0 zombie
cpu(s):  0.3%us,0.0%sy,99.7%id,0.0%wa,504528k used,6340k free,3084k buffers
Swap:  1047544k total,179784k used,867760k free,19532k cached

  PID USER      PR  NI  VIRT  RES  SHR S %cpu %MEM    TIME+  COMMAND
19041 Nginx     20   0 58672  22m 2660 S  0.0  4.5  24:00.18 PHP-fpm
17805 Nginx     20   0 58672  22m 2688 S  0.0  4.5  16:46.40 PHP-fpm
19040 Nginx     20   0 58776  17m 2684 S  0.0  3.6  24:27.53 PHP-fpm
19046 Nginx     20   0 53412  17m 2692 S  0.0  3.5  22:51.54 PHP-fpm
17796 Nginx     20   0 53604  16m 2648 S  0.0  3.3  15:14.62 PHP-fpm
19042 Nginx     20   0 52144  15m 2660 S  0.0  3.0  22:16.40 PHP-fpm
17186 Nginx     20   0 52208  15m 2656 S  0.0  3.0  25:22.13 PHP-fpm
24580 Nginx     20   0 50600  14m 2660 S  0.0  3.0  13:23.23 PHP-fpm
19014 Nginx     20   0 52084  14m 2692 S  0.0  3.0  22:16.57 PHP-fpm
19007 Nginx     20   0 58724  14m 2724 S  0.0  3.0  25:09.20 PHP-fpm
19032 Nginx     20   0 50156  14m 2692 S  0.0  3.0  24:25.53 PHP-fpm
17830 Nginx     20   0 50088  14m 2696 S  0.0  2.9  16:37.53 PHP-fpm
17816 Nginx     20   0 49996  14m 2768 S  0.0  2.9  18:57.37 PHP-fpm
19043 Nginx     20   0 50140  14m 2648 S  0.0  2.9  23:30.66 PHP-fpm
17806 Nginx     20   0 50088  14m 2656 S  0.0  2.9  19:38.99 PHP-fpm
17188 Nginx     20   0 50100  14m 2656 S  0.0  2.9  22:46.46 PHP-fpm
17817 Nginx     20   0 49836  14m 2660 S  0.0  2.9  18:29.45 PHP-fpm
17820 Nginx     20   0 48892  13m 2972 S  0.0  2.8  18:01.07 PHP-fpm
19030 Nginx     20   0 58824  13m 2652 S  0.0  2.8  23:40.90 PHP-fpm
17798 Nginx     20   0 48780  13m 2696 S  0.0  2.7  17:09.82 PHP-fpm
17187 Nginx     20   0 58672  13m 2716 S  0.0  2.7  23:04.46 PHP-fpm
17807 Nginx     20   0 52076  13m 2660 S  0.0  2.6  16:45.52 PHP-fpm
19029 Nginx     20   0 58924  12m 2688 S  0.0  2.6  24:00.66 PHP-fpm
17808 Nginx     20   0 58676  12m 2688 S  0.0  2.6  17:31.33 PHP-fpm
17799 Nginx     20   0 50088  12m 2660 S  0.0  2.6  17:41.13 PHP-fpm
19015 Nginx     20   0 58680  12m 2656 S  0.0  2.6  21:59.83 PHP-fpm
18295 Nginx     20   0 48512  12m 2692 S  0.0  2.6  16:57.08 PHP-fpm
19027 Nginx     20   0 48368  12m 2656 S  0.0  2.6  24:40.65 PHP-fpm
17819 Nginx     20   0 48208  12m 2656 S  0.0  2.5  16:43.87 PHP-fpm
19031 Nginx     20   0 49960  12m 2648 S  0.0  2.5  23:28.34 PHP-fpm
17832 Nginx     20   0 47884  12m 2660 S  0.0  2.5  16:04.87 PHP-fpm
17818 Nginx     20   0 47884  12m 2660 S  0.0  2.5  16:03.53 PHP-fpm
17831 Nginx     20   0 47864  12m 2696 S  0.0  2.5  16:43.48 PHP-fpm
18249 Nginx     20   0 47884  12m 2664 S  0.0  2.5  16:27.29 PHP-fpm
 7435 MysqL     20   0  352m 7780 2872 S  0.3  1.5  62:00.00 MysqLd
19033 Nginx     20   0 42540 7368 2676 S  0.0  1.4  24:04.93 PHP-fpm
31015 root      20   0 12028 3708 2940 S  0.0  0.7   0:00.17 sshd
30826 postfix   20   0 13628 2260 1640 S  0.0  0.4   0:00.00 pickup
30995 root      20   0  5252 1704 1412 S  0.0  0.3   0:00.03 bash
31020 root      20   0  5256 1704 1416 S  0.0  0.3   0:00.03 bash
19028 Nginx     20   0 58668 1648 1528 S  0.0  0.3   9:11.84 PHP-fpm

解决方法

我们可以从您更新的输出中看到您有34个PHP工作程序正在运行(不包括主进程),所有这些都占用内存并且完全空闲.这意味着你已经调整了PHP-fpm以在更大容量的机器上运行,远远超过你实际获得的流量.或者,或许,根本没有调整它.

目前,这些进程占用了VM的3/4以上,并且绝对没有任何好处.

因此,检查PHP-fpm池配置中的调优,例如默认的/etc/PHP-fpm.d/www.conf.对于像这样的小型VPS,我可能会在某处开始:

pm = dynamic
pm.max_children = 10
pm.start_servers = 3
pm.min_spare_servers = 3
pm.max_spare_servers = 5
原文链接:https://www.f2er.com/linux/395473.html

猜你在找的Linux相关文章