Welcome! Log In Create A New Profile

Advanced

Huge memory leaks here, really need help.

Posted by anthonyk 
Huge memory leaks here, really need help.
June 11, 2014 12:57PM
Hi,
I need some help with a server running a single website. The memory is increasing really fast, about 1GB per day.
Restarting php-fpm and nginx is not freeing any memory.
I need to reboot the whole server every 15 days, I can't figure out the problem since 4 months now.

Here is the status and conf files, I hope you can help ;)

Using
- Nginx/1.4.5
- PHP 5.5.3-1ubuntu2.3
- APCu Version 4.0.1
- Memcached and php memcache


Memcache status :
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 status
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 status :
Active connections: 146
server accepts handled requests
8792651 8792651 17113216
Reading: 0 Writing: 11 Waiting: 135


php fpm status :
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 command :
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


File : 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


File : 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


File : 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

Thank you !
regards,
Anthony
Re: Huge memory leaks here, really need help.
July 27, 2014 06:12AM
Try to
pm = dynamic
pm.max_requests = 500
pm.process_idle_timeout = 10s;
Re: Huge memory leaks here, really need help.
August 06, 2014 08:16AM
Same thing. I wonder how can I found what is really in memory ? datas, cached pages, etc.
Re: Huge memory leaks here, really need help.
August 06, 2014 08:45AM
Try http://newrelic.com/
Re: Huge memory leaks here, really need help.
August 09, 2014 06:17AM
I was already on newrelic, and I just added the plugins "fpm" "ram" "nginx" "apc" "memcached" to monitor them on newrelic.
Here are the strange results :

- PHP FPM is what is consuming the most of ram, but it seems to be quite constant (1.7G)
- The total memory used is quite constant as well, between 2.5G and 5G
- But there is a "wired" memory that is increasing really fast and I can't find anymore informations about that
Do you have any idea of what it is or what can I do to track it and free it ?


FPM processes : http://postimg.org/image/yyddgnfd5/

Memory stats : http://postimg.org/image/zdon9o1ah/

Top memory consumers : http://postimg.org/image/fhsnu4k95/

Thank you so much for your help !
Re: Huge memory leaks here, really need help.
February 02, 2018 01:52PM
you may try other tools

check memory usage process

ps -eo pid,ppid,cmd,%mem,%cpu --sort=-%mem | head

check php-fpm child process memory

ps -eo size,pid,user,command --sort -size | awk '{ hr=$1/1024 ; printf("%13.2f Mb ",hr) } { for ( x=4 ; x<=NF ; x++ ) { printf("%s ",$x) } print "" }' | grep php-fpm
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 156
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready