Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:47932 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 5169 invoked from network); 14 Apr 2010 07:30:01 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 14 Apr 2010 07:30:01 -0000 Authentication-Results: pb1.pair.com smtp.mail=jerome@loyet.net; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=jerome@loyet.net; sender-id=unknown Received-SPF: error (pb1.pair.com: domain loyet.net from 74.125.78.27 cause and error) X-PHP-List-Original-Sender: jerome@loyet.net X-Host-Fingerprint: 74.125.78.27 ey-out-2122.google.com Received: from [74.125.78.27] ([74.125.78.27:28557] helo=ey-out-2122.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id F0/4B-07606-7FE65CB4 for ; Wed, 14 Apr 2010 03:30:00 -0400 Received: by ey-out-2122.google.com with SMTP id d26so602154eyd.39 for ; Wed, 14 Apr 2010 00:29:57 -0700 (PDT) MIME-Version: 1.0 Received: by 10.239.135.83 with HTTP; Wed, 14 Apr 2010 00:29:56 -0700 (PDT) In-Reply-To: References: Date: Wed, 14 Apr 2010 09:29:56 +0200 Received: by 10.103.3.39 with SMTP id f39mr3835229mui.83.1271230196641; Wed, 14 Apr 2010 00:29:56 -0700 (PDT) Message-ID: To: =?UTF-8?B?5ruV6Lev6YGl?= Cc: internals@lists.php.net Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] One suggestion to PHP-FPM From: jerome@loyet.net (=?ISO-8859-1?B?Suly9G1lIExveWV0?=) 2010/4/6 =E6=BB=95=E8=B7=AF=E9=81=A5 : > 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/1882a= 3b2257dcc5c/ea73892cea011541?lnk=3Dgst&q=3Dgaochunhui#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 " name=3D"term_on_memory_limit">3145728" in the "global_options" se= ction, > when PHP's memory beyond this limit,child process will exit. > > mypatch.diff http://docs.google.com/leaf?id=3D0B-ig5wUi7GTMZTUxYjg1ZTQtOG= Q5Zi00N2Q1LTkxODYtYWQ4Y2FiMzhlOWM5&hl=3Den<%20http://docs.google.com/leaf?i= d=3D0B-ig5wUi7GTMZTUxYjg1ZTQtOGQ5Zi00N2Q1LTkxODYtYWQ4Y2FiMzhlOWM5&hl=3Den> > =C2=A0This patch is for > http://svn.php.net/repository/php/php-src/branches/PHP_5_3_FPM version: > 294187. > thanks, I'll review the patch. But I don't have time right now. It's in my todo list. ++ Jerome