Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:47952 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 14579 invoked from network); 15 Apr 2010 07:41:56 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 15 Apr 2010 07:41:56 -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 72.14.220.152 cause and error) X-PHP-List-Original-Sender: jerome@loyet.net X-Host-Fingerprint: 72.14.220.152 fg-out-1718.google.com Received: from [72.14.220.152] ([72.14.220.152:38124] helo=fg-out-1718.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 67/F3-20494-343C6CB4 for ; Thu, 15 Apr 2010 03:41:56 -0400 Received: by fg-out-1718.google.com with SMTP id 22so2362000fge.11 for ; Thu, 15 Apr 2010 00:41:52 -0700 (PDT) MIME-Version: 1.0 Received: by 10.239.135.83 with HTTP; Thu, 15 Apr 2010 00:41:52 -0700 (PDT) In-Reply-To: References: <4BC58D10.4050609@lerdorf.com> Date: Thu, 15 Apr 2010 09:41:52 +0200 Received: by 10.239.165.73 with SMTP id w9mr493049hbd.144.1271317312231; Thu, 15 Apr 2010 00:41:52 -0700 (PDT) Message-ID: To: Ferenc Kovacs Cc: =?UTF-8?B?5ruV6Lev6YGl?= , Rasmus Lerdorf , 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/15 Ferenc Kovacs : > > > On Thu, Apr 15, 2010 at 9:25 AM, J=C3=A9r=C3=B4me Loyet wrote: >> >> 2010/4/15 Ferenc Kovacs : >> > >> > >> > On Thu, Apr 15, 2010 at 9:09 AM, Ferenc Kovacs wrot= e: >> >> >> >> >> >> 2010/4/15 J=C3=A9r=C3=B4me Loyet >> >>> >> >>> 2010/4/15 =E6=BB=95=E8=B7=AF=E9=81=A5 : >> >>> > We check error log after our server crashed, and we found that php >> >>> > heap >> >>> > memory is out of limit, >> >>> > so I think imagick use emalloc to allocate php heap memory, to che= ck >> >>> > the >> >>> > zend_memory_usage is >> >>> > not a method for imagick, other circumstances which occupy huge >> >>> > memory >> >>> > can >> >>> > use this method to >> >>> > ensure the system have enough free memory. >> >>> >> >>> OK, >> >>> >> >>> one thing I didn't understand is "why should you want check de zend >> >>> memory usage when there is a memory_limit parameter in PHP.ini " ? >> >>> does'nt it do the same at PHP layer when allocating ? >> >>> >> >> >> >> Obviously you didn't read the original mail, and the links inside: >> >> >> >> >> >> http://groups.google.com/group/highload-php-en/browse_thread/thread/1= 882a3b2257dcc5c/ea73892cea011541?lnk=3Dgst&q=3Dgaochunhui#ea73892cea011541 >> >> >> >> The problem here is that PHP wouldn't free any allocated memory until= l >> >> 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". >> >> >> >> So one of your lib (for example imagick) leaks memory, on the long ru= n, >> >> it >> >> will exhaust the memory limit, and will kill a totaly request. >> >> You can set that how many request should be served with one worker, b= ut >> >> you can't soft limit it's memory consumption. >> >> This is what the patch does: >> >> if you set the hard limit: (memory_limit) you can guarante that no >> >> process >> >> will use more memory, because if it tries, it will fail. >> >> and you can set soft limit, if that reached, the process will die and >> >> respawn after finishing the current request. >> >> >> >> Tyrael >> > >> > Btw: did you know about >> > http://php.net/manual/en/function.apache-child-terminate.php I just >> > noticed >> > a few days ago, obviously, you can't use with cgi/fastcgi/php-fpm but >> > for >> > apache, it does exactly what you need, except that you have to execute >> > from >> > userland. >> >> This function is interesting but it's called from php scripts. When >> you are a sysadmin who host hundreds of different customers, you can't >> garanty each customer will call this function each time he uses >> consomption scripts. > > Yeah, I know, and I think I did mention that, but this sounds like a good > feature in the language, but sadly it has too many limitation in it's > current form. (no windows support, only works with apache) I see how soft_limit could work (after processing a page, memory is checked and if it's more than the soft limit, the process is killed). But how can you make the hard_limit to work ? You'll have to setup memory check for each process by a master process, because the child won't be able to check it's memory realtime (or I missed something) ++ Jerome