nginx - PHP-FPM using a lot memory

331

I'm using PHP-FPM to serve dynamic content to nginx through fastcgi. Everything is working fine except that the PHP-FPM proccesses are using so much memory. According to new relic process monitor PHP-FPM have 6 processes running and combined they are using 220+ MB. Doesn't seem normal to me? What could be the problem?

929

Answer

Solution:

A couple things to check are/ tips to debug in a development environment:

  • Could you set the php memory_limit to 35M and see where PHP errors out?
  • Are there any large database queries being ran?
  • Are you using APC with PHP, what is your shared memory size (shm)?
  • If you are familiar with xDebug (http://xdebug.org/). You could use the xDebug profiler (http://xdebug.org/docs/profiler), to see what is using memory. That is your best bet IMO.
  • PHP-FPM allows you to set a max request parameter (pm.max_requests) that will restart a child process after a certain amount of requests. Watch out setting that to low might result in poor performance, and odd behavior under load.

To be honest 37M per process is high, however I have seen applications like Magento get close to that, so there may be no problem. Hope that helps.

People are also looking for solutions to the problem: node.js - How do I generate a token in PHP to post the my Express-based app?

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.