hi, We use PHP's Imagemagick extension to process images, and this would consume a lot of memory under some circumstances. However, the mainstream PHP's memory management is really weak, so a huge amount of memory would be consumed under high server load. What's worse, this even cause our server to crash frequently.
So I suggest that if we could add a config option to PHP-FPM, so that PHP-FPM could just kill a PHP process if it consumes too much memory (say more than 256M). This would prevent PHP from consuming a lot of memory which couldn't be freed later. For example, assuming that this option is "exit_on_memory_exceeds", and I set it to 256M. Also, I set PHP's "memory_limit" option to 1024M. I would expect PHP-FPM to kill the PHP process which consumes more than 256M memory, even though PHP could use up to 1024M memory. We have discussed this idea with the author of PHP-FPM,url is http://groups.google.com/group/highload-php-en/browse_thread/thread/1882a3b2257dcc5c/ea73892cea011541?lnk=gst&q=gaochunhui#ea73892cea011541 , and now I have reach my goal by patching the source code of PHP-FPM. So we can edit the php-fpm.conf and add one item such as "<value name="term_on_memory_limit">3145728</value>" in the "global_options" section, when PHP's memory beyond this limit,child process will exit. mypatch.diff http://docs.google.com/leaf?id=0B-ig5wUi7GTMZTUxYjg1ZTQtOGQ5Zi00N2Q1LTkxODYtYWQ4Y2FiMzhlOWM5&hl=en<%20http://docs.google.com/leaf?id=0B-ig5wUi7GTMZTUxYjg1ZTQtOGQ5Zi00N2Q1LTkxODYtYWQ4Y2FiMzhlOWM5&hl=en> This patch is for http://svn.php.net/repository/php/php-src/branches/PHP_5_3_FPM version: 294187.