繁体   English   中英

使用 nginx + php-fpm 导致内存泄漏

[英]Memory leaks with nginx + php-fpm

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

这是状态和配置文件,我希望你能帮助;)

使用

  • Nginx/1.4.5 PHP 5.5.3-1ubuntu2.3

  • APCu 版本 4.0.1

  • Memcached 和 php 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

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 状态:

Active connections: 146
server accepts handled requests
8792651 8792651 17113216
Reading: 0 Writing: 11 Waiting: 135

php fpm 状态:

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

文件:pool.d/www.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

文件:sysctl.conf

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

谢谢 ! 问候, 安东尼

内存泄漏通常是错误编程的原因。 检查您的代码库。 最好尝试找到一种强制垃圾收集的方法。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM