a new suggest about php-fpm

111 views
Skip to first unread message

高春辉

unread,
Dec 25, 2008, 2:07:42 AM12/25/08
to highload-php-en

We're using PHP-FPM to manage PHP FastCGI processes, and I have a
suggestion that I want to discuss with anderi and you:

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.

I believe such option could improve memory efficiency, reduce the use
of swap memory, and prevent our server from crashing frequently.

So I hope you could think about this suggestion.

Regards,

Paul Gao.

shunz

unread,
Dec 25, 2008, 2:12:07 AM12/25/08
to highloa...@googlegroups.com
I support Paul Gao.
--
                          顺子 ( http://shunz.net/ )

Zhang Erning

unread,
Dec 25, 2008, 2:19:06 AM12/25/08
to highloa...@googlegroups.com
+1.

We use the same approach to process images. and also have the problem
about memory usage. I do think this improvement would help a lot.

Erning

On Thu, Dec 25, 2008 at 3:07 PM, 高春辉 <gaoch...@gmail.com> wrote:
>
>

mike

unread,
Dec 25, 2008, 2:25:43 AM12/25/08
to highloa...@googlegroups.com, highloa...@googlegroups.com
+1.

It would be cool to add this since there is a wallclock seconds
termination too. Just helps force more limits.


On Dec 24, 2008, at 11:19 PM, "Zhang Erning" <zend...@gmail.com>
wrote:

Marcos Neves

unread,
Dec 25, 2008, 7:39:21 AM12/25/08
to highloa...@googlegroups.com
Why the current PHP memory_limit didn´t works?

Marcos Neves
+55 44 3263-8132
+55 44 9918-8488

2008/12/25 mike <mik...@gmail.com>:

Andrei Nigmatulin

unread,
Dec 25, 2008, 7:48:57 AM12/25/08
to highloa...@googlegroups.com, Marcos Neves
On Thursday 25 December 2008 15:39, Marcos Neves wrote:
> Why the current PHP memory_limit didn´t works?

I think this limit only affected internal php memory allocation, not 3rd party
libraries.

Implementing such config option in php-fpm should not be too difficult, need
to check.


--
Andrei Nigmatulin
GPG PUB KEY 6449830D

Now I lay me down to sleep(3)
Pray the OS my core to keep
If I die before I wake
Pray the Disk my core to take

Zhang Erning

unread,
Dec 25, 2008, 8:45:57 PM12/25/08
to highloa...@googlegroups.com
On Thu, Dec 25, 2008 at 8:39 PM, Marcos Neves <marcos...@gmail.com> wrote:
> Why the current PHP memory_limit didn´t works?

php will report error and stop execution if it exhausted the 'memory_limit'.

we want the php process continue execute even it exceeds
'exit_on_memory_exceeds'. but exit and spawn a new one after the
script finished.

Erning

高春辉

unread,
Dec 25, 2008, 9:31:43 PM12/25/08
to highload-php-en
The problem here is that PHP wouldn't free any allocated memory untill
the process exits, so there's the risk of memory exhaustion if too
many PHP processes were running, even though each process wouldn't
exceed PHP's memory_limit.

My suggestion is more about releasing the allocated memory as soon as
possible. That is, this option is similar to "max_requests".

PHP-FPM would kill the PHP process if the requests a process handled
exceed max_requests, and similarly, PHP-FPM should kill the PHP
process whose memory usage exceeds "exit_on_memory_exceeds".

On 12月25日, 下午8时39分, "Marcos Neves" <marcos.ne...@gmail.com> wrote:
> Why the current PHP memory_limit didn´t works?
>
> Marcos Neves
> +55 44 3263-8132
> +55 44 9918-8488
>
> 2008/12/25 mike <mike...@gmail.com>:
>
>
>
> > +1.
>
> > It would be cool to add this since there is a wallclock seconds termination
> > too. Just helps force more limits.
>
> > On Dec 24, 2008, at 11:19 PM, "Zhang Erning" <zendra...@gmail.com> wrote:
>
> >> +1.
>
> >> We use the same approach to process images. and also have the problem
> >> about memory usage. I do think this improvement would help a lot.
>
> >> Erning
>
Reply all
Reply to author
Forward
0 new messages