使用nginx+的内存泄漏;php fpm

使用nginx+的内存泄漏;php fpm,nginx,php,Nginx,Php,我需要一些关于运行单个网站的服务器的帮助。内存增长非常快,大约每天1GB。 重新启动php fpm和nginx不会释放任何内存。 我需要每15天重新启动一次整个服务器,4个月以来我一直无法解决这个问题 这是状态和conf文件,希望您能提供帮助;) 使用 Nginx/1.4.5 PHP 5.5.3-1ubuntu2.3 APCu版本4.0.1 Memcached和php memcache Memcache状态: Free: 46.3 MBytes (72.4%) Used: 17.7 MByt

我需要一些关于运行单个网站的服务器的帮助。内存增长非常快,大约每天1GB。 重新启动php fpm和nginx不会释放任何内存。 我需要每15天重新启动一次整个服务器,4个月以来我一直无法解决这个问题

这是状态和conf文件,希望您能提供帮助;)

使用

  • Nginx/1.4.5 PHP 5.5.3-1ubuntu2.3

  • APCu版本4.0.1

  • Memcached和php memcache

Memcache状态:

Free: 46.3 MBytes (72.4%)
Used: 17.7 MBytes (27.6%)
Hits: 30985436 (60.3%)
Misses: 20412444 (39.7%)
Used Cache Size 17.7 MBytes
Total Cache Size 64.0 MBytes
Active connections: 146
server accepts handled requests
8792651 8792651 17113216
Reading: 0 Writing: 11 Waiting: 135
pool: www
process manager: static
start time: 05/Jun/2014:09:44:04 +0200
start since: 549019
accepted conn: 62499
listen queue: 0
max listen queue: 0
listen queue len: 0
idle processes: 33
active processes: 27
total processes: 60
max active processes: 61
max children reached: 0
slow requests: 14236
top - 18:13:51 up 6 days, 8:29, 1 user, load average: 0,56, 0,57, 0,66
Tasks: 193 total, 2 running, 191 sleeping, 0 stopped, 0 zombie
%Cpu(s): 13,6 us, 1,0 sy, 0,0 ni, 85,1 id, 0,0 wa, 0,0 hi, 0,3 si, 0,0 st
KiB Mem: 32840792 total, 9399012 used, 23441780 free, 465028 buffers
KiB Swap: 1046520 total, 0 used, 1046520 free, 1931844 cached
APCu状态

Free: 1023.4 MBytes (99.9%)
Used: 637.7 KBytes (0.1%)
Hits: 40594423 (100.0%)
Misses: 428 (0.0%)
Request Rate (hits, misses) 73.83 cache requests/second
Hit Rate 73.83 cache requests/second
Nginx状态:

Free: 46.3 MBytes (72.4%)
Used: 17.7 MBytes (27.6%)
Hits: 30985436 (60.3%)
Misses: 20412444 (39.7%)
Used Cache Size 17.7 MBytes
Total Cache Size 64.0 MBytes
Active connections: 146
server accepts handled requests
8792651 8792651 17113216
Reading: 0 Writing: 11 Waiting: 135
pool: www
process manager: static
start time: 05/Jun/2014:09:44:04 +0200
start since: 549019
accepted conn: 62499
listen queue: 0
max listen queue: 0
listen queue len: 0
idle processes: 33
active processes: 27
total processes: 60
max active processes: 61
max children reached: 0
slow requests: 14236
top - 18:13:51 up 6 days, 8:29, 1 user, load average: 0,56, 0,57, 0,66
Tasks: 193 total, 2 running, 191 sleeping, 0 stopped, 0 zombie
%Cpu(s): 13,6 us, 1,0 sy, 0,0 ni, 85,1 id, 0,0 wa, 0,0 hi, 0,3 si, 0,0 st
KiB Mem: 32840792 total, 9399012 used, 23441780 free, 465028 buffers
KiB Swap: 1046520 total, 0 used, 1046520 free, 1931844 cached
php fpm状态:

Free: 46.3 MBytes (72.4%)
Used: 17.7 MBytes (27.6%)
Hits: 30985436 (60.3%)
Misses: 20412444 (39.7%)
Used Cache Size 17.7 MBytes
Total Cache Size 64.0 MBytes
Active connections: 146
server accepts handled requests
8792651 8792651 17113216
Reading: 0 Writing: 11 Waiting: 135
pool: www
process manager: static
start time: 05/Jun/2014:09:44:04 +0200
start since: 549019
accepted conn: 62499
listen queue: 0
max listen queue: 0
listen queue len: 0
idle processes: 33
active processes: 27
total processes: 60
max active processes: 61
max children reached: 0
slow requests: 14236
top - 18:13:51 up 6 days, 8:29, 1 user, load average: 0,56, 0,57, 0,66
Tasks: 193 total, 2 running, 191 sleeping, 0 stopped, 0 zombie
%Cpu(s): 13,6 us, 1,0 sy, 0,0 ni, 85,1 id, 0,0 wa, 0,0 hi, 0,3 si, 0,0 st
KiB Mem: 32840792 total, 9399012 used, 23441780 free, 465028 buffers
KiB Swap: 1046520 total, 0 used, 1046520 free, 1931844 cached
top命令:

Free: 46.3 MBytes (72.4%)
Used: 17.7 MBytes (27.6%)
Hits: 30985436 (60.3%)
Misses: 20412444 (39.7%)
Used Cache Size 17.7 MBytes
Total Cache Size 64.0 MBytes
Active connections: 146
server accepts handled requests
8792651 8792651 17113216
Reading: 0 Writing: 11 Waiting: 135
pool: www
process manager: static
start time: 05/Jun/2014:09:44:04 +0200
start since: 549019
accepted conn: 62499
listen queue: 0
max listen queue: 0
listen queue len: 0
idle processes: 33
active processes: 27
total processes: 60
max active processes: 61
max children reached: 0
slow requests: 14236
top - 18:13:51 up 6 days, 8:29, 1 user, load average: 0,56, 0,57, 0,66
Tasks: 193 total, 2 running, 191 sleeping, 0 stopped, 0 zombie
%Cpu(s): 13,6 us, 1,0 sy, 0,0 ni, 85,1 id, 0,0 wa, 0,0 hi, 0,3 si, 0,0 st
KiB Mem: 32840792 total, 9399012 used, 23441780 free, 465028 buffers
KiB Swap: 1046520 total, 0 used, 1046520 free, 1931844 cached
文件:php fpm.conf

[global]
pid = /var/run/php5-fpm.pid
error_log = /var/log/php/php5-fpm.log
log_level = notice
emergency_restart_threshold = 10
emergency_restart_interval = 1m
process_control_timeout = 20s
include=/etc/php5/fpm/pool.d/*.conf
[www]
user = www-data
group = www-data
listen = /var/run/php5-fpm.sock
listen.backlog = 65536
pm = static
pm.max_children = 60
pm.start_servers = 5
pm.min_spare_servers = 5
pm.max_spare_servers = 10
pm.max_requests = 5000
pm.status_path = /php-status
ping.path = /php-ping
slowlog = /var/log/php/$pool.log.slow
request_slowlog_timeout = 30s
request_terminate_timeout = 120s
rlimit_files = 131072
rlimit_core = unlimited
chdir = /
catch_workers_output = yes
security.limit_extensions = .php .php3 .php4 .php5 .jpg
net.ipv6.conf.all.autoconf = 0
net.ipv6.conf.default.autoconf = 0
net.ipv6.conf.eth0.autoconf = 0
net.ipv6.conf.all.accept_ra = 0
net.ipv6.conf.default.accept_ra = 0
net.ipv6.conf.eth0.accept_ra = 0
net.core.somaxconn=65535
fs.file-max = 100000
kernel.pid_max = 1048576
net.core.wmem_max = 1048576
net.core.optmem_max = 1048576
vm.max_map_count = 262144
net.core.rmem_max = 1048576
文件:pool.d/www.conf

[global]
pid = /var/run/php5-fpm.pid
error_log = /var/log/php/php5-fpm.log
log_level = notice
emergency_restart_threshold = 10
emergency_restart_interval = 1m
process_control_timeout = 20s
include=/etc/php5/fpm/pool.d/*.conf
[www]
user = www-data
group = www-data
listen = /var/run/php5-fpm.sock
listen.backlog = 65536
pm = static
pm.max_children = 60
pm.start_servers = 5
pm.min_spare_servers = 5
pm.max_spare_servers = 10
pm.max_requests = 5000
pm.status_path = /php-status
ping.path = /php-ping
slowlog = /var/log/php/$pool.log.slow
request_slowlog_timeout = 30s
request_terminate_timeout = 120s
rlimit_files = 131072
rlimit_core = unlimited
chdir = /
catch_workers_output = yes
security.limit_extensions = .php .php3 .php4 .php5 .jpg
net.ipv6.conf.all.autoconf = 0
net.ipv6.conf.default.autoconf = 0
net.ipv6.conf.eth0.autoconf = 0
net.ipv6.conf.all.accept_ra = 0
net.ipv6.conf.default.accept_ra = 0
net.ipv6.conf.eth0.accept_ra = 0
net.core.somaxconn=65535
fs.file-max = 100000
kernel.pid_max = 1048576
net.core.wmem_max = 1048576
net.core.optmem_max = 1048576
vm.max_map_count = 262144
net.core.rmem_max = 1048576
文件:sysctl.conf

[global]
pid = /var/run/php5-fpm.pid
error_log = /var/log/php/php5-fpm.log
log_level = notice
emergency_restart_threshold = 10
emergency_restart_interval = 1m
process_control_timeout = 20s
include=/etc/php5/fpm/pool.d/*.conf
[www]
user = www-data
group = www-data
listen = /var/run/php5-fpm.sock
listen.backlog = 65536
pm = static
pm.max_children = 60
pm.start_servers = 5
pm.min_spare_servers = 5
pm.max_spare_servers = 10
pm.max_requests = 5000
pm.status_path = /php-status
ping.path = /php-ping
slowlog = /var/log/php/$pool.log.slow
request_slowlog_timeout = 30s
request_terminate_timeout = 120s
rlimit_files = 131072
rlimit_core = unlimited
chdir = /
catch_workers_output = yes
security.limit_extensions = .php .php3 .php4 .php5 .jpg
net.ipv6.conf.all.autoconf = 0
net.ipv6.conf.default.autoconf = 0
net.ipv6.conf.eth0.autoconf = 0
net.ipv6.conf.all.accept_ra = 0
net.ipv6.conf.default.accept_ra = 0
net.ipv6.conf.eth0.accept_ra = 0
net.core.somaxconn=65535
fs.file-max = 100000
kernel.pid_max = 1048576
net.core.wmem_max = 1048576
net.core.optmem_max = 1048576
vm.max_map_count = 262144
net.core.rmem_max = 1048576
谢谢大家!! 当做
Anthony

内存泄漏通常是编程错误的原因。检查你的代码库。更好的办法是找到强制垃圾收集的方法。

您是否尝试过将池配置中的fpm pm设置设置为
ondemand
?我以前使用的是“dynamic”,但不是“ondemand”,因为它不适合只有一个站点的情况。我问这个问题是因为它值得测试。查看是否是fpm首先导致问题。