Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am using Nginx+PHP-FPM with php 5.3.6 and it was working well for weeks. A few days before I found out that most of the PHP-FPM children take 3MB but a few children are taking 700MB. The web application is busy with 1000 requests/second. PHP-FPM is used with APC (opcode use)

Can anybody guide on this?

This script I used to get memory usage by child pid 
 http://www.pixelbeat.org/scripts/ps_mem.py.

It could be verified by 'top' method too

top output(limited view)::
------------------------------
------------------------------
28419 daemon    20   0  844m 757m 4200 S    0  6.4   0:14.27 php-fpm                                                          

16788 daemon    20   0  700m 614m 4632 S    0  5.2   0:28.34 php-fpm                                                          

29450 daemon    20   0  669m 581m 3548 S    0  4.9   0:08.31 php-fpm                                                          

17881 daemon    20   0  642m 556m 4108 S    0  4.7   0:14.83 php-fpm                                                          

19048 daemon    20   0  642m 555m 4108 S    0  4.7   0:08.86 php-fpm 
11956 daemon    20   0 97612  10m 5476 S    4  0.1   0:39.57 php-fpm                                                          
11993 daemon    20   0 97560  10m 5188 S    4  0.1   0:39.18 php-fpm                                                          
11925 daemon    20   0 97328  10m 5144 D    3  0.1   0:38.68 php-fpm                                                          
11953 daemon    20   0 97748  10m 5172 S    4  0.1   0:38.51 php-fpm   

php-fpm.conf:

/etc/php-fpm/php-fpm.conf
listen = 127.0.0.1:9000
user = daemon
group = daemon

pm = dynamic
pm.max_children = 2000
pm.start_servers = 50
pm.min_spare_servers = 40
pm.max_spare_servers = 90
pm.max_requests = 10000

Following are the more debug inputs:

pmap::

pmap 28419
0000000000b52000     96K rw---    [ anon ]
0000000001a49000   1668K rw---    [ anon ]
0000000001bea000    208K rw---    [ anon ]
0000000001c1e000 770476K rw---    [ anon ]

strace::

strace -p 28419
Process 28419 attached - interrupt to quit
restart_syscall(<... resuming interrupted call ...>) = 0
recvfrom(4, 0x1bda1d0, 8196, 64, 0, 0)  = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=4, events=POLLIN}], 1, 5000)  = 0 (Timeout)
recvfrom(4, 0x1bda1d0, 8196, 64, 0, 0)  = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=4, events=POLLIN}], 1, 5000^C <unfinished ...>

PHP Modules loaded are::

[PHP Modules]
apc
Core
date
ereg
hash
json
libxml
mbstring
mcrypt
memcache
memcached
mysql
mysqli
pcntl
pcre
Reflection
session
SimpleXML
SPL
standard
xml
share|improve this question
    
Is memory usage the same after restart service nginx and php-fpm ?? –  B14D3 Mar 19 '13 at 8:09
    
No, the memory usage drops after restart but gradually it happens again for few php-fpm children. –  amolrajoba Mar 19 '13 at 10:28

1 Answer 1

Try lowering the max requests to something like pm.max_requests = 100. This will restart the process after 100 requests, freeing memory that might have been lost due to memory leaks in your scripts.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.