php-fpm 池进程每个占用 250MB

php-fpm 池进程每个占用 250MB

我的 centos 6.7 服务器只有基于 php 和 mysql 的低流量网站(所有网站每天的总页面浏览量约为 3000 次),使用 nginx 网络服务器和 virtualmin(没有 wordpress 或外部脚本/软件)。

我使用以下命令安装 PHP:

yum --enablerepo=remi,remi-php56 install -y php-mysqlnd php-gd php-fpm

yum 安装了依赖项,例如 php-commom、php-pdo 等。

我使用 virtualmin 检查了服务器中正在运行的进程。

重新启动 php-fpm 后,每个 php-fpm:pool www进程正在使用400MB记忆。

etc/php.d 目录中有 20 多个扩展。

我注释了 etc/php.d 目录中的大部分扩展。

重新启动 php-fpm 和 nginx 后,

我使用以下方法检查了已安装的扩展

<?php
print_r(get_loaded_extensions());
?>

结果如下:

[0] => Core
[1] => date
[2] => ereg
[3] => libxml
[4] => openssl
[5] => pcre
[6] => zlib
[7] => filter
[8] => hash
[9] => Reflection
[10] => SPL
[11] => session
[12] => standard
[13] => cgi-fcgi
[14] => curl
[15] => ftp
[16] => gd
[17] => mysqlnd
[18] => PDO
[19] => mysql
[20] => pdo_mysql
[21] => json
[22] => mhash

现在重新启动 php-fpm 后,每个 php-fpm:池 www进程正在使用250MB记忆 。

www.conf :

pm = dynamic
pm.max_children = 50
pm.start_servers = 5
pm.min_spare_servers = 5
pm.max_spare_servers = 35

在 php.ini 中

memory_limit = 128M

在 virtualmin 中运行进程:

 Real memory: 31.19 GB total / 21.17 GB free / 20.24 GB cached   Swap space: 1024 MB total / 341.19 MB free

ID      Owner       Size        Command   
46929   mysql   10.48 GB    /usr/sbin/mysqld --basedir=/usr --datadir=/home/mysql-data --plugin-dir=/var/lib ...
45061   dkim-milter     1.96 GB     /usr/sbin/dkim-filter -x /etc/mail/dkim-milter/dkim-filter.conf -P /var/run/dkim ...
27380   sphinx  1.19 GB     /usr/bin/searchd --config /etc/sphinx/sphinx.conf
45056   named   709.38 MB   /usr/sbin/named -u named
56055   apache  614.07 MB   php-fpm: pool www
25919   apache  317.67 MB   php-fpm: pool www
19624   apache  305.90 MB   php-fpm: pool www
16654   apache  300.36 MB   php-fpm: pool www
24973   apache  295.33 MB   php-fpm: pool www
24559   apache  291.47 MB   php-fpm: pool www
30654   apache  285.20 MB   php-fpm: pool www
50347   apache  285.09 MB   php-fpm: pool www
19531   apache  254.57 MB   php-fpm: pool www
33874   apache  254.42 MB   php-fpm: pool www
15467   apache  253.65 MB   php-fpm: pool www
42002   apache  253.01 MB   php-fpm: pool www
40159   apache  251.92 MB   php-fpm: pool www
48884   apache  251.05 MB   php-fpm: pool www
1568    root    250.19 MB   /sbin/rsyslogd -i /var/run/syslogd.pid -c 5
7628    apache  249.05 MB   php-fpm: pool www
52524   apache  247.92 MB   php-fpm: pool www
897     apache  247.14 MB   php-fpm: pool www
19972   apache  246.92 MB   php-fpm: pool www
44322   apache  246.64 MB   php-fpm: pool www
56975   apache  246.50 MB   php-fpm: pool www
28549   apache  246.42 MB   php-fpm: pool www
25728   apache  246.09 MB   php-fpm: pool www
65048   root    245.55 MB   php-fpm: master process (/etc/php-fpm.conf)
46044   root    105.76 MB   /bin/sh /usr/bin/mysqld_safe --datadir=/home/mysql-data --socket=/var/lib/mysql/ ...
43584   root    98.25 MB    /usr/libexec/webmin/proc/index_size.cgi
59312   root    97.63 MB    sshd: root@notty
27379   sphinx  90.30 MB    /usr/bin/searchd --config /etc/sphinx/sphinx.conf
15861   root    86.25 MB    /usr/bin/perl /usr/libexec/webmin/miniserv.pl /etc/webmin/miniserv.conf
43585   root    86.25 MB    /usr/bin/perl /usr/libexec/webmin/miniserv.pl /etc/webmin/miniserv.conf
43589   root    86.25 MB    /usr/bin/perl /usr/libexec/webmin/miniserv.pl /etc/webmin/miniserv.conf
35690   postfix     79.22 MB    qmgr -l -t fifo -u
2723    postfix     79.05 MB    pickup -l -t fifo -u
39868   root    78.97 MB    /usr/libexec/postfix/master
24373   root    64.85 MB    /usr/sbin/saslauthd -m /var/run/saslauthd -a pam -r
24374   root    64.85 MB    /usr/sbin/saslauthd -m /var/run/saslauthd -a pam -r
24375   root    64.85 MB    /usr/sbin/saslauthd -m /var/run/saslauthd -a pam -r
24376   root    64.85 MB    /usr/sbin/saslauthd -m /var/run/saslauthd -a pam -r
24377   root    64.85 MB    /usr/sbin/saslauthd -m /var/run/saslauthd -a pam -r
10485   root    64.67 MB    /usr/sbin/sshd
59383   root    56.03 MB    /usr/libexec/openssh/sftp-server
42540   nginx   54.42 MB    nginx: worker process
42545   nginx   54.19 MB    nginx: worker process
42539   nginx   53.52 MB    nginx: worker process
42542   nginx   53.52 MB    nginx: worker process
42543   nginx   53.36 MB    nginx: worker process
42538   nginx   53.32 MB    nginx: worker process
42546   nginx   53.32 MB    nginx: worker process
42544   nginx   53.23 MB    nginx: worker process
42537   root    49.33 MB    nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf

最佳结果:按内存使用情况排序:

 PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
46929 mysql     20   0 10.5g 5.3g 4992 S  1.0 17.0 369:43.82 mysqld
27380 sphinx    20   0 1218m 463m 433m S  6.0  1.5 266:34.64 searchd
56055 apache    20   0  614m 373m 3964 S  2.3  1.2   5:09.57 php-fpm
25919 apache    20   0  323m  84m 5260 S  4.0  0.3   3:32.51 php-fpm
19624 apache    20   0  306m  66m 5048 S  4.6  0.2   7:02.03 php-fpm
16654 apache    20   0  300m  60m 4288 S  0.3  0.2   0:49.27 php-fpm
24973 apache    20   0  295m  54m 3944 S  0.7  0.2   1:18.91 php-fpm
45056 named     20   0  709m  51m 2500 S  0.7  0.2  21:01.48 named
24559 apache    20   0  291m  51m 4988 S  0.0  0.2   1:08.85 php-fpm
50347 apache    20   0  286m  46m 4964 S  1.3  0.1   0:40.13 php-fpm
30654 apache    20   0  285m  34m 7400 S  0.7  0.1   2:09.37 php-fpm
15861 root      20   0 88320  17m 1888 S  0.0  0.1   0:10.77 miniserv.pl
15467 apache    20   0  253m  15m 5428 S  0.0  0.0   0:28.92 php-fpm
42002 apache    20   0  253m  14m 5036 S  0.0  0.0   0:01.19 php-fpm
33874 apache    20   0  254m  14m 4012 S  0.0  0.0   1:48.74 php-fpm
42540 nginx     20   0 55724  12m 1052 S  0.0  0.0   0:11.45 nginx
42545 nginx     20   0 55492  12m 1052 S  0.0  0.0   0:12.47 nginx
40159 apache    20   0  251m  12m 4036 S  0.0  0.0   0:01.16 php-fpm
42539 nginx     20   0 54804  11m 1056 S  0.0  0.0   0:11.76 nginx
42542 nginx     20   0 54804  11m 1052 S  0.0  0.0   0:12.55 nginx
42543 nginx     20   0 54636  11m 1052 S  0.0  0.0   0:12.48 nginx
42544 nginx     20   0 54508  11m 1056 S  0.0  0.0   0:11.07 nginx
42546 nginx     20   0 54604  11m 1052 S  0.0  0.0   0:12.52 nginx
42538 nginx     20   0 54604  11m 1052 S  0.0  0.0   0:13.75 nginx
48884 apache    20   0  251m  11m 3996 S  0.0  0.0   0:01.19 php-fpm
52524 apache    20   0  247m 9800 3452 S  0.0  0.0   0:01.17 php-fpm
 7628 apache    20   0  249m 9296 3964 S  0.0  0.0   0:00.92 php-fpm
  897 apache    20   0  247m 8824 3460 S  0.0  0.0   0:01.07 php-fpm
19972 apache    20   0  246m 8300 3472 S  0.0  0.0   0:00.79 php-fpm
25728 apache    20   0  246m 7680 3436 S  0.0  0.0   0:00.38 php-fpm
28549 apache    20   0  246m 7404 3056 S  0.0  0.0   0:00.31 php-fpm
44322 apache    20   0  246m 7300 3088 S  0.0  0.0   0:00.65 php-fpm
56975 apache    20   0  246m 7220 3116 S  0.0  0.0   0:00.51 php-fpm
17463 apache    20   0  246m 7208 2968 S  0.0  0.0   0:00.05 php-fpm
42537 root      20   0 50516 6936  296 S  0.0  0.0   0:00.00 nginx
 1568 root      20   0  250m 6264  868 S  0.0  0.0   0:34.28 rsyslogd

点击查看按内存使用量排序的最佳结果

如果您想了解更多详细信息,请回复。

请提出建议。

谢谢。

相关内容