PHP-FPM进程正在增长并且内存越来越多

时间:2018-06-18 19:06:33

标签: php memory memory-leaks

我有一些php-fpm的过程一直在增长。

显示使用的内存(使用ps命令)显示此内容。

我尝试了两件事:

1)strace,但是有大量的信息。这是一个Symfony框架,我看到大量文件被访问或打开,但根本没有任何线索。无休止的日志...每1或2或3秒,它突然显示2000行痕迹。

我明白这一点:

fstat(7, {st_mode=S_IFREG|0644, st_size=1029, ...}) = 0
fstat(7, {st_mode=S_IFREG|0644, st_size=1029, ...}) = 0
fstat(7, {st_mode=S_IFREG|0644, st_size=1029, ...}) = 0
mmap(NULL, 1029, PROT_READ, MAP_SHARED, 7, 0) = 0x7f88da53d000
munmap(0x7f88da53d000, 1029)            = 0
close(7)                                = 0
chdir("/")                              = 0
clock_gettime(CLOCK_MONOTONIC, {21720, 148391054}) = 0
times({tms_utime=6933, tms_stime=7614, tms_cutime=0, tms_cstime=0}) = 1720128933
close(11)                               = 0
setitimer(ITIMER_PROF, {it_interval={0, 0}, it_value={0, 0}}, NULL) = 0
umask(022)                              = 0
sendto(12, "\1\0\0\0\1", 5, MSG_DONTWAIT, NULL, 0) = 5
close(12)                               = 0
fcntl(6, F_SETLK, {l_type=F_UNLCK, l_whence=SEEK_SET, l_start=0, l_len=0}) = 0
munmap(0x7f88ba000000, 2097152)         = 0
setitimer(ITIMER_PROF, {it_interval={0, 0}, it_value={0, 0}}, NULL) = 0
clock_gettime(CLOCK_MONOTONIC, {21720, 149294252}) = 0
accept(0, 

然后它停止1-5秒,它显示了2000行的框架的许多lstat文件...像这样的块的houndreds(这是一个例子,但所有块不同

lstat("/var/www/vhosts/mywebsite.com/vendor/composer/../symfony/swiftmailer-bundle/DependencyInjection/SmtpTransportConfigurator.php", {st_mode=S_IFREG|0644, st_size=1029, ...}) = 0
lstat("/var/www/vhosts/mywebsite.com/vendor/composer/../symfony/swiftmailer-bundle/DependencyInjection", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
lstat("/var/www/vhosts/mywebsite.com/vendor/composer/../symfony/swiftmailer-bundle", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
lstat("/var/www/vhosts/mywebsite.com/vendor/composer/../symfony", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
lstat("/var/www/vhosts/mywebsite.com/vendor/composer", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
lstat("/var/www/vhosts/mywebsite.com/vendor", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
lstat("/var/www/vhosts/mywebsite.com", {st_mode=S_IFDIR|0775, st_size=4096, ...}) = 0
lstat("/var/www/vhosts/mywebsite.com", {st_mode=S_IFDIR|0710, st_size=4096, ...}) = 0
lstat("/var/www/vhosts", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
lstat("/var/www", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
lstat("/var", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0

2)lsof但我无法获得有关脚本的信息或原因。

COMMAND   PID        USER   FD   TYPE             DEVICE SIZE/OFF    NODE NAME
php-fpm 25690 www_plesk  cwd    DIR              202,1     4096       2 /
php-fpm 25690 www_plesk  rtd    DIR              202,1     4096       2 /
php-fpm 25690 www_plesk  txt    REG              202,1  4821232 1537261 /opt/plesk/php/7.2/sbin/php-fpm
php-fpm 25690 www_plesk  DEL    REG                0,5          1406882 /dev/zero
php-fpm 25690 www_plesk  DEL    REG                0,5          1406876 /dev/zero
php-fpm 25690 www_plesk  mem    REG              202,1    27000    1985 /lib/x86_64-linux-gnu/libnss_dns-2.23.so
php-fpm 25690 www_plesk  mem    REG              202,1    26258   24695 /usr/lib/x86_64-linux-gnu/gconv/gconv-modules.cache
php-fpm 25690 www_plesk  DEL    REG                0,5          1406861 /dev/zero
php-fpm 25690 www_plesk  mem    REG              202,1    47600    1991 /lib/x86_64-linux-gnu/libnss_files-2.23.so
php-fpm 25690 www_plesk  mem    REG              202,1    47648    1995 /lib/x86_64-linux-gnu/libnss_nis-2.23.so
php-fpm 25690 www_plesk  mem    REG              202,1    93128    1968 /lib/x86_64-linux-gnu/libnsl-2.23.so
php-fpm 25690 www_plesk  mem    REG              202,1    35688    1983 /lib/x86_64-linux-gnu/libnss_compat-2.23.so
php-fpm 25690 www_plesk  mem    REG              202,1   134624 1328699 /opt/plesk/php/7.2/lib/php/modules/zip.so
php-fpm 25690 www_plesk  mem    REG              202,1   247952   50760 /usr/lib/x86_64-linux-gnu/libxslt.so.1.1.28
php-fpm 25690 www_plesk  mem    REG              202,1    83816   50761 /usr/lib/x86_64-linux-gnu/libexslt.so.0.8.17
php-fpm 25690 www_plesk  mem    REG              202,1    31752 1328672 /opt/plesk/php/7.2/lib/php/modules/xsl.so
php-fpm 25690 www_plesk  mem    REG              202,1    47816 1328671 /opt/plesk/php/7.2/lib/php/modules/xmlwriter.so
php-fpm 25690 www_plesk  mem    REG              202,1    81096 1328675 /opt/plesk/php/7.2/lib/php/modules/xmlrpc.so
php-fpm 25690 www_plesk  mem    REG              202,1    31528 1328674 /opt/plesk/php/7.2/lib/php/modules/xmlreader.so
php-fpm 25690 www_plesk  mem    REG              202,1   383544   53078 /usr/lib/libtidy-0.99.so.0.0.0
php-fpm 25690 www_plesk  mem    REG              202,1    52360 1328682 /opt/plesk/php/7.2/lib/php/modules/tidy.so
php-fpm 25690 www_plesk  mem    REG              202,1    14792 1328666 /opt/plesk/php/7.2/lib/php/modules/sysvshm.so
php-fpm 25690 www_plesk  mem    REG              202,1    10600 1328667 /opt/plesk/php/7.2/lib/php/modules/sysvsem.so
php-fpm 25690 www_plesk  mem    REG              202,1    14888 1328669 /opt/plesk/php/7.2/lib/php/modules/sysvmsg.so
php-fpm 25690 www_plesk  mem    REG              202,1   998080 1328679 /opt/plesk/php/7.2/lib/php/modules/sqlite3.so
php-fpm 25690 www_plesk  mem    REG              202,1   303432 1328693 /opt/plesk/php/7.2/lib/php/modules/soap.so
php-fpm 25690 www_plesk  mem    REG              202,1   695312   51937 /usr/lib/x86_64-linux-gnu/libaspell.so.15.2.0
php-fpm 25690 www_plesk  mem    REG              202,1    23080 1328670 /opt/plesk/php/7.2/lib/php/modules/pspell.so
php-fpm 25690 www_plesk  mem    REG              202,1    35816 1328668 /opt/plesk/php/7.2/lib/php/modules/posix.so
php-fpm 25690 www_plesk  mem    REG              202,1   270512 1328697 /opt/plesk/php/7.2/lib/php/modules/phar.so
php-fpm 25690 www_plesk  mem    REG              202,1   139048 1328680 /opt/plesk/php/7.2/lib/php/modules/pgsql.so
php-fpm 25690 www_plesk  mem    REG              202,1    27896 1328677 /opt/plesk/php/7.2/lib/php/modules/pdo_sqlite.so
php-fpm 25690 www_plesk  mem    REG              202,1   194544    9381 /usr/lib/x86_64-linux-gnu/libpq.so.5.8
php-fpm 25690 www_plesk  mem    REG              202,1    44600 1328681 /opt/plesk/php/7.2/lib/php/modules/pdo_pgsql.so
php-fpm 25690 www_plesk  mem    REG              202,1    27768 1328687 /opt/plesk/php/7.2/lib/php/modules/pdo_odbc.so
php-fpm 25690 www_plesk  mem    REG              202,1    31672 1328684 /opt/plesk/php/7.2/lib/php/modules/pdo_mysql.so
php-fpm 25690 www_plesk  mem    REG              202,1   110168 1328678 /opt/plesk/php/7.2/lib/php/modules/pdo.so
php-fpm 25690 www_plesk  mem    REG              202,1   427552   51744 /usr/lib/x86_64-linux-gnu/libodbc.so.2.0.0
php-fpm 25690 www_plesk  mem    REG              202,1    68680 1328686 /opt/plesk/php/7.2/lib/php/modules/odbc.so
php-fpm 25690 www_plesk  mem    REG              202,1   134296 1328683 /opt/plesk/php/7.2/lib/php/modules/mysqli.so
php-fpm 25690 www_plesk  mem    REG              202,1  1674464 1328665 /opt/plesk/php/7.2/lib/php/modules/mbstring.so
php-fpm 25690 www_plesk  mem    REG              202,1    72872 1328691 /opt/plesk/php/7.2/lib/php/modules/ldap.so
php-fpm 25690 www_plesk  mem    REG              202,1    43624 1328700 /opt/plesk/php/7.2/lib/php/modules/json.so
php-fpm 25690 www_plesk  mem    REG              202,1    55304   25752 /usr/lib/x86_64-linux-gnu/libicuio.so.55.1
php-fpm 25690 www_plesk  mem    REG              202,1  2496856   25754 /usr/lib/x86_64-linux-gnu/libicui18n.so.55.1
php-fpm 25690 www_plesk  mem    REG              202,1   482160 1328692 /opt/plesk/php/7.2/lib/php/modules/intl.so
php-fpm 25690 www_plesk  mem    REG              202,1   117288    2603 /lib/x86_64-linux-gnu/libaudit.so.1.0.0
php-fpm 25690 www_plesk  mem    REG              202,1    55904   21215 /lib/x86_64-linux-gnu/libpam.so.0.83.1
php-fpm 25690 www_plesk  mem    REG              202,1  1100216   50574 /usr/lib/libc-client.so.2007e.0
php-fpm 25690 www_plesk  mem    REG              202,1    89480 1328695 /opt/plesk/php/7.2/lib/php/modules/imap.so
php-fpm 25690 www_plesk  mem    REG              202,1   166032    1979 /lib/x86_64-linux-gnu/libexpat.so.1.6.0
php-fpm 25690 www_plesk  mem    REG              202,1    39272   50718 /usr/lib/x86_64-linux-gnu/libltdl.so.7.3.1
php-fpm 25690 www_plesk  mem    REG              202,1    73640   25834 /usr/lib/x86_64-linux-gnu/libXext.so.6.4.0
php-fpm 25690 www_plesk  mem    REG              202,1   273832   51273 /usr/lib/x86_64-linux-gnu/libfontconfig.so.1.9.0
php-fpm 25690 www_plesk  mem    REG              202,1  2087104   51314 /usr/lib/x86_64-linux-gnu/libfftw3.so.3.4.4
php-fpm 25690 www_plesk  mem    REG              202,1    96504   51337 /usr/lib/x86_64-linux-gnu/liblqr-1.so.0.3.2
php-fpm 25690 www_plesk  mem    REG              202,1   353392   51331 /usr/lib/x86_64-linux-gnu/liblcms2.so.2.0.6
php-fpm 25690 www_plesk  mem    REG              202,1   138448   51307 /usr/lib/x86_64-linux-gnu/libgomp.so.1.0.0
php-fpm 25690 www_plesk  mem    REG              202,1  2707304    9717 /usr/lib/x86_64-linux-gnu/libMagickCore-6.Q16.so.2.0.0
php-fpm 25690 www_plesk  mem    REG              202,1  1200744    6527 /usr/lib/x86_64-linux-gnu/libMagickWand-6.Q16.so.2.0.0
php-fpm 25690 www_plesk  mem    REG              202,1   426816 1328701 /opt/plesk/php/7.2/lib/php/modules/imagick.so
php-fpm 25690 www_plesk  mem    REG              202,1    22640   25828 /usr/lib/x86_64-linux-gnu/libXdmcp.so.6.0.0
php-fpm 25690 www_plesk  mem    REG              202,1    14456   25826 /usr/lib/x86_64-linux-gnu/libXau.so.6.0.0
php-fpm 25690 www_plesk  mem    REG              202,1   137728   25830 /usr/lib/x86_64-linux-gnu/libxcb.so.1.1.0
php-fpm 25690 www_plesk  mem    REG              202,1  1285552   25832 /usr/lib/x86_64-linux-gnu/libX11.so.6.3.0
php-fpm 25690 www_plesk  mem    REG              202,1   694800   25840 /usr/lib/x86_64-linux-gnu/libfreetype.so.6.12.1
php-fpm 25690 www_plesk  mem    REG              202,1   363264   51325 /usr/lib/x86_64-linux-gnu/libjpeg.so.8.0.2
php-fpm 25690 www_plesk  mem    REG              202,1   149904    2138 /lib/x86_64-linux-gnu/libpng12.so.0.54.0
php-fpm 25690 www_plesk  mem    REG              202,1    72520   51670 /usr/lib/x86_64-linux-gnu/libXpm.so.4.11.0
php-fpm 25690 www_plesk  mem    REG              202,1   389088 1328694 /opt/plesk/php/7.2/lib/php/modules/gd.so
php-fpm 25690 www_plesk  mem    REG              202,1  5045800 1328698 /opt/plesk/php/7.2/lib/php/modules/fileinfo.so
php-fpm 25690 www_plesk  mem    REG              202,1  1115136    2154 /lib/x86_64-linux-gnu/libglib-2.0.so.0.4800.2
php-fpm 25690 www_plesk  mem    REG              202,1    14656   25804 /usr/lib/x86_64-linux-gnu/libgmodule-2.0.so.0.4800.2
php-fpm 25690 www_plesk  mem    REG              202,1    46944   52829 /usr/lib/x86_64-linux-gnu/libenchant.so.1.6.0
php-fpm 25690 www_plesk  mem    REG              202,1    23904 1328688 /opt/plesk/php/7.2/lib/php/modules/enchant.so
php-fpm 25690 www_plesk  mem    REG              202,1   172216 1328673 /opt/plesk/php/7.2/lib/php/modules/dom.so
php-fpm 25690 www_plesk  mem    REG              202,1  1756696   24914 /usr/lib/x86_64-linux-gnu/libdb-5.3.so
php-fpm 25690 www_plesk  mem    REG              202,1    52776 1328690 /opt/plesk/php/7.2/lib/php/modules/dba.so
php-fpm 25690 www_plesk  mem    REG              202,1    39224    1997 /lib/x86_64-linux-gnu/libcrypt-2.23.so
php-fpm 25690 www_plesk  mem    REG              202,1   870240   25802 /usr/lib/x86_64-linux-gnu/libsqlite3.so.0.8.6
php-fpm 25690 www_plesk  mem    REG              202,1   304072   25885 /usr/lib/x86_64-linux-gnu/libhx509.so.5.0.0
php-fpm 25690 www_plesk  mem    REG              202,1    60928   25881 /usr/lib/x86_64-linux-gnu/libheimbase.so.1.0.0
php-fpm 25690 www_plesk  mem    REG              202,1   166128   25883 /usr/lib/x86_64-linux-gnu/libwind.so.0.0.0
php-fpm 25690 www_plesk  mem    REG              202,1    31104   25780 /usr/lib/x86_64-linux-gnu/libffi.so.6.0.4
php-fpm 25690 www_plesk  mem    REG              202,1    89904   25873 /usr/lib/x86_64-linux-gnu/libroken.so.18.1.0
php-fpm 25690 www_plesk  mem    REG              202,1   204168   25878 /usr/lib/x86_64-linux-gnu/libhcrypto.so.4.1.0
php-fpm 25690 www_plesk  mem    REG              202,1   661872   25875 /usr/lib/x86_64-linux-gnu/libasn1.so.8.0.0
php-fpm 25690 www_plesk  mem    REG              202,1   560808   25887 /usr/lib/x86_64-linux-gnu/libkrb5.so.26.0.0
php-fpm 25690 www_plesk  mem    REG              202,1    35920   25889 /usr/lib/x86_64-linux-gnu/libheimntlm.so.0.1.0
php-fpm 25690 www_plesk  mem    REG              202,1    14256    2172 /lib/x86_64-linux-gnu/libkeyutils.so.1.5
php-fpm 25690 www_plesk  mem    REG              202,1    76192   25740 /usr/lib/x86_64-linux-gnu/libtasn1.so.6.5.1
php-fpm 25690 www_plesk  mem    REG              202,1   408472   25738 /usr/lib/x86_64-linux-gnu/libp11-kit.so.0.1.0
php-fpm 25690 www_plesk  mem    REG              202,1   264256   25891 /usr/lib/x86_64-linux-gnu/libgssapi.so.3.0.0
php-fpm 25690 www_plesk  mem    REG              202,1   109296   25916 /usr/lib/x86_64-linux-gnu/libsasl2.so.2.0.25
php-fpm 25690 www_plesk  mem    REG              202,1    43664   25861 /usr/lib/x86_64-linux-gnu/libkrb5support.so.0.1
php-fpm 25690 www_plesk  mem    REG              202,1    14648    1960 /lib/x86_64-linux-gnu/libcom_err.so.2.1
php-fpm 25690 www_plesk  mem    REG              202,1   186872   25865 /usr/lib/x86_64-linux-gnu/libk5crypto.so.3.1
php-fpm 25690 www_plesk  mem    REG              202,1   860392   25867 /usr/lib/x86_64-linux-gnu/libkrb5.so.3.3
php-fpm 25690 www_plesk  mem    REG              202,1   219336   25734 /usr/lib/x86_64-linux-gnu/libnettle.so.6.2
php-fpm 25690 www_plesk  mem    REG              202,1   207640   25732 /usr/lib/x86_64-linux-gnu/libhogweed.so.4.2
php-fpm 25690 www_plesk  mem    REG              202,1  1239440   25744 /usr/lib/x86_64-linux-gnu/libgnutls.so.30.6.2
php-fpm 25690 www_plesk  mem    REG              202,1   322928   10117 /usr/lib/x86_64-linux-gnu/libldap_r-2.4.so.2.10.5
php-fpm 25690 www_plesk  mem    REG              202,1    59640   10118 /usr/lib/x86_64-linux-gnu/liblber-2.4.so.2.10.5
php-fpm 25690 www_plesk  mem    REG              202,1   301376   25869 /usr/lib/x86_64-linux-gnu/libgssapi_krb5.so.2.2
php-fpm 25690 www_plesk  mem    REG              202,1   113584   25923 /usr/lib/x86_64-linux-gnu/librtmp.so.1
php-fpm 25690 www_plesk  mem    REG              202,1   207208   25736 /usr/lib/x86_64-linux-gnu/libidn.so.11.6.15
php-fpm 25690 www_plesk  mem    REG              202,1   452992   10557 /usr/lib/x86_64-linux-gnu/libcurl.so.4.4.0
php-fpm 25690 www_plesk  mem    REG              202,1    89256 1287184 /opt/plesk/php/7.2/lib/php/modules/curl.so
php-fpm 25690 www_plesk  mem    REG              202,1    35344 1328676 /opt/plesk/php/7.2/lib/php/modules/bcmath.so
php-fpm 25690 www_plesk  mem    REG              202,1   256760 1328685 /opt/plesk/php/7.2/lib/php/modules/mysqlnd.so
php-fpm 25690 www_plesk  mem    REG              202,1 15185280 2826090 /opt/dynatrace/oneagent/agent/lib64/liboneagentphp.so
php-fpm 25690 www_plesk  mem    REG              202,1  4816792 2826084 /opt/dynatrace/oneagent/agent/lib64/liboneagentloader.so
php-fpm 25690 www_plesk  mem    REG              202,1   438752 1328689 /opt/plesk/php/7.2/lib/php/modules/opcache.so
php-fpm 25690 www_plesk  mem    REG              202,1  1385896 1283865 /opt/plesk/php/7.2/lib/php/modules/ioncube_loader_lin_7.2.so
php-fpm 25690 www_plesk  DEL    REG                0,5          1406862 /dev/zero
php-fpm 25690 www_plesk  mem    REG              202,1  1668976   28956 /usr/lib/locale/locale-archive
php-fpm 25690 www_plesk  mem    REG              202,1    89696    1965 /lib/x86_64-linux-gnu/libgcc_s.so.1
php-fpm 25690 www_plesk  mem    REG              202,1  1566440   51083 /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21
php-fpm 25690 www_plesk  mem    REG              202,1 25913104   25753 /usr/lib/x86_64-linux-gnu/libicudata.so.55.1
php-fpm 25690 www_plesk  mem    REG              202,1    80496    2002 /lib/x86_64-linux-gnu/libgpg-error.so.0.17.0
php-fpm 25690 www_plesk  mem    REG              202,1   456632    2066 /lib/x86_64-linux-gnu/libpcre.so.3.13.2
php-fpm 25690 www_plesk  mem    REG              202,1  1636360   25757 /usr/lib/x86_64-linux-gnu/libicuuc.so.55.1
php-fpm 25690 www_plesk  mem    REG              202,1   919168    1001 /lib/x86_64-linux-gnu/libgcrypt.so.20.0.5
php-fpm 25690 www_plesk  mem    REG              202,1   137400    2004 /lib/x86_64-linux-gnu/liblzma.so.5.0.0
php-fpm 25690 www_plesk  mem    REG              202,1   130224    2073 /lib/x86_64-linux-gnu/libselinux.so.1
php-fpm 25690 www_plesk  mem    REG              202,1    18624    2107 /lib/x86_64-linux-gnu/libattr.so.1.1.0
php-fpm 25690 www_plesk  mem    REG              202,1   138696    1970 /lib/x86_64-linux-gnu/libpthread-2.23.so
php-fpm 25690 www_plesk  mem    REG              202,1  1868984    1971 /lib/x86_64-linux-gnu/libc-2.23.so
php-fpm 25690 www_plesk  mem    REG              202,1  2361856   21565 /lib/x86_64-linux-gnu/libcrypto.so.1.0.0
php-fpm 25690 www_plesk  mem    REG              202,1   428384   21561 /lib/x86_64-linux-gnu/libssl.so.1.0.0
php-fpm 25690 www_plesk  mem    REG              202,1  1809656   25949 /usr/lib/x86_64-linux-gnu/libxml2.so.2.9.3
php-fpm 25690 www_plesk  mem    REG              202,1    31232    1987 /lib/x86_64-linux-gnu/libacl.so.1.1.0
php-fpm 25690 www_plesk  mem    REG              202,1    14608    1973 /lib/x86_64-linux-gnu/libdl-2.23.so
php-fpm 25690 www_plesk  mem    REG              202,1  1088952    1967 /lib/x86_64-linux-gnu/libm-2.23.so
php-fpm 25690 www_plesk  mem    REG              202,1    31712    1996 /lib/x86_64-linux-gnu/librt-2.23.so
php-fpm 25690 www_plesk  mem    REG              202,1   104864    2120 /lib/x86_64-linux-gnu/libz.so.1.2.8
php-fpm 25690 www_plesk  mem    REG              202,1    66800    2111 /lib/x86_64-linux-gnu/libbz2.so.1.0.4
php-fpm 25690 www_plesk  mem    REG              202,1   522664   25784 /usr/lib/x86_64-linux-gnu/libgmp.so.10.3.0
php-fpm 25690 www_plesk  mem    REG              202,1   101200    1975 /lib/x86_64-linux-gnu/libresolv-2.23.so
php-fpm 25690 www_plesk  mem    REG              202,1   548432     747 /lib/x86_64-linux-gnu/liboneagentproc.so
php-fpm 25690 www_plesk  mem    REG              202,1   162632    1969 /lib/x86_64-linux-gnu/ld-2.23.so
php-fpm 25690 www_plesk  DEL    REG                0,5          1406870 /dev/zero
php-fpm 25690 www_plesk  DEL    REG                0,5          1406867 /dev/zero
php-fpm 25690 www_plesk  DEL    REG                0,5          1406866 /dev/zero
php-fpm 25690 www_plesk  DEL    REG                0,5          1406865 /dev/zero
php-fpm 25690 www_plesk  DEL    REG                0,5          1406864 /dev/zero
php-fpm 25690 www_plesk  DEL    REG                0,5          1406863 /dev/zero
php-fpm 25690 www_plesk  DEL    REG                0,5          1406846 /dev/zero
php-fpm 25690 www_plesk  DEL    REG                0,5          1406845 /dev/zero
php-fpm 25690 www_plesk  DEL    REG                0,5          1406844 /dev/zero
php-fpm 25690 www_plesk  DEL    REG                0,5          1406843 /dev/zero
php-fpm 25690 www_plesk  DEL    REG                0,5          1406842 /dev/zero
php-fpm 25690 www_plesk  DEL    REG                0,5          1406841 /dev/zero
php-fpm 25690 www_plesk  DEL    REG                0,5          1406840 /dev/zero
php-fpm 25690 www_plesk  DEL    REG                0,5          1406839 /dev/zero
php-fpm 25690 www_plesk  mem    REG              202,1   536520    2093 /lib/x86_64-linux-gnu/libsystemd.so.0.14.0
php-fpm 25690 www_plesk    0u  unix 0xffff8803a285a000      0t0 1406893 /var/www/vhosts/system/mywebsite.com/php-fpm.sock type=STREAM
php-fpm 25690 www_plesk    1w  FIFO               0,10      0t0 1407453 pipe
php-fpm 25690 www_plesk    2w  FIFO               0,10      0t0 1407454 pipe
php-fpm 25690 www_plesk    3r   CHR                1,9      0t0      11 /dev/urandom
php-fpm 25690 www_plesk    4w   CHR                1,8      0t0      10 /dev/random
php-fpm 25690 www_plesk    6u   REG              202,1        0  513276 /tmp/.ZendSem.1t93Xa (deleted)
php-fpm 25690 www_plesk    8r   CHR                1,9      0t0      11 /dev/urandom
php-fpm 25690 www_plesk    9w  FIFO               0,10      0t0 1406869 pipe
php-fpm 25690 www_plesk   11u  unix 0xffff8803a2bf8800      0t0 1418861 type=STREAM

是否有其他机会获取脚本的真实信息?

更多信息:

顶部

的一部分
top - 21:13:22 up  6:11,  2 users,  load average: 0.84, 0.92, 0.89
Tasks: 206 total,   1 running, 205 sleeping,   0 stopped,   0 zombie
%Cpu(s): 15.5 us,  5.4 sy,  0.0 ni, 78.8 id,  0.1 wa,  0.0 hi,  0.2 si,  0.2 st
KiB Mem : 16431376 total,  8608756 free,  2660328 used,  5162292 buff/cache
KiB Swap:  1048572 total,  1048572 free,        0 used. 13156496 avail Mem 

  PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND                                                                                                                        
 9573 www_p+  20   0  631700  99808  54084 S  30.9  0.6   0:01.86 php-fpm                                                                                                                        
 9645 www_p+  20   0  603164  50004  27864 S  11.6  0.3   0:00.35 php                                                                                                                            
26995 www_p+  20   0  773664 231460  43620 S   6.6  1.4   2:06.97 php-fpm                                                                                                                        
25685 www_p+  20   0  778512 238372  43632 S   3.7  1.5   2:57.93 php-fpm                                                                                                                        
25688 www_p+  20   0  793032 251636  42408 S   3.7  1.5   2:16.99 php-fpm                                                                                                                        
25940 www_p+  20   0  789220 250440  45004 S   3.7  1.5   2:14.46 php-fpm                                                                                                                        
25690 www_p+  20   0  861668 251364  47144 S   2.3  1.5   2:27.00 php-fpm                                                                                                                        
25831 www_p+  20   0  862860 251556  46112 S   2.3  1.5   2:20.00 php-fpm 

使用-c属性(10秒)输出其中一个(php-fpm)的strace:

% time     seconds  usecs/call     calls    errors syscall
------ ----------- ----------- --------- --------- ----------------
 63.17    0.018411           0    409063       700 lstat
 27.45    0.008000         727        11           accept
  2.45    0.000713           0     20071           fstat
  2.00    0.000584           0      6582           mmap
  1.45    0.000424           0      6905           close
  1.21    0.000353           0      6872           open
  1.04    0.000304           0      6588           munmap
  0.38    0.000110           0      3065           clock_gettime
  0.15    0.000043           0       247           lseek
  0.15    0.000043           1        33           sendto
  0.14    0.000041           0       912           read
  0.09    0.000027           0      1214           gettimeofday
  0.09    0.000026           3         9           brk
  0.08    0.000022           0       383        31 stat
  0.08    0.000022           0       706       288 access
  0.07    0.000020           0        55           fcntl
  0.00    0.000000           0        32           write
  0.00    0.000000           0       384           poll
  0.00    0.000000           0        88           rt_sigaction
  0.00    0.000000           0        11           rt_sigprocmask
  0.00    0.000000           0        22           ioctl
  0.00    0.000000           0         6           madvise
  0.00    0.000000           0        44           setitimer
  0.00    0.000000           0        21           socket
  0.00    0.000000           0        21        11 connect
  0.00    0.000000           0       375           recvfrom
  0.00    0.000000           0        11           shutdown
  0.00    0.000000           0        22           setsockopt
  0.00    0.000000           0        11           getsockopt
  0.00    0.000000           0        11           getcwd
  0.00    0.000000           0        22           chdir
  0.00    0.000000           0       350       350 readlink
  0.00    0.000000           0        33           umask
  0.00    0.000000           0        22           times
  0.00    0.000000           0         1           restart_syscall
  0.00    0.000000           0        10           sendmmsg
------ ----------- ----------- --------- --------- ----------------
100.00    0.029143                464213      1380 total

注意:

  • 没有涉及crontabs
  • 如果我杀死其中一个公羊消费者的成长过程,他们会再次开始(从大约30Mb开始,然后再慢慢增长......)每15分钟增加约100Mb ....

1 个答案:

答案 0 :(得分:1)

内存使用的主要问题是您需要附加调试器或分析器进行诊断,并且很可能是应用程序本身内存泄漏而不是PHP固有的任何内容。作为权宜之计,您可以将FPM配置为更频繁地回收其工作人员以释放累积的内存。

http://php.net/manual/en/install.fpm.configuration.php#pm.max-requests

你遇到的第二个问题是你的作曲家自动加载器仍在每次加载时遍历文件系统,这似乎是你有如此大量lstat次调用的原因。这对你的内存使用没有影响,但是很多不必要的IO可以很简单地避免:

https://getcomposer.org/doc/articles/autoloader-optimization.md#optimization-level-1-class-map-generation