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'm running an Ubuntu 10.04 nginx webserver with PHP-FPM. It has 512MB of total memory (256MB swap). After starting the PHP-FPM process (/etc/init.d/php5-fpm start), it uses an acceptable ~100MB for about 5 children. But then the processes suddenly balloon to using 400MB.

Here's a graph of my server's memory usage with PHP-FPM.

Here's my PHP process memory usage (ps aux | grep php)

I have set my PHP-FPM config conservatively: pm = static and pm.max_children = 5. I'm only running a few Wordpress blogs, and I don't get that many visitors.

How can I control the memory usage of PHP-FPM's processes so it doesn't eat up my server?

share|improve this question
add comment

1 Answer

up vote 0 down vote accepted
  • Disable any PHP extensions that you don't need.
  • Set a low max requests per child so each process is restarted more often.
  • Reduce the number of processes. You don't need many for a small blog. 2 should be fine.
share|improve this answer
    
I set the max requests to 4 and the number of processes to 3. Now my memory usage looks like this: i.imgur.com/jChLX.png –  mr_schlomo Jan 7 '12 at 16:39
    
Max requests is really too low. The processes will be restarted too often (too much CPU time wasted). I would suggest 32 max requests/child and 2 processes. Try and see which PHP extensions are causing the high memory usage too; it shouldn't really be that high in the first place. –  diolemo Jan 7 '12 at 21:17
    
It is a good thing to have high buffer/cache usage by the way. This memory can be freed by the OS if needed but will improve performance if not needed. –  diolemo Jan 7 '12 at 21:22
add comment

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.