Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:47946 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 5643 invoked from network); 15 Apr 2010 07:09:21 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 15 Apr 2010 07:09:21 -0000 Authentication-Results: pb1.pair.com header.from=tyra3l@gmail.com; sender-id=pass; domainkeys=bad Authentication-Results: pb1.pair.com smtp.mail=tyra3l@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.218.219 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: tyra3l@gmail.com X-Host-Fingerprint: 209.85.218.219 mail-bw0-f219.google.com Received: from [209.85.218.219] ([209.85.218.219:63120] helo=mail-bw0-f219.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 19/12-20494-E9BB6CB4 for ; Thu, 15 Apr 2010 03:09:20 -0400 Received: by bwz19 with SMTP id 19so164247bwz.1 for ; Thu, 15 Apr 2010 00:09:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:received:message-id:subject:from:to:cc:content-type; bh=rsnDVMpHHDw3zMDXkTgpgqyqM6F+GMsHoHrz9nhQPDw=; b=Ao6An4V1ORxlan58PGoT0JwfCy/a/3ZoAERUW6/OzZD5qs3FxynU+1VRP3QCqSLNkI hsmMQU3UJcRptSCzL9JnN1R9Unlikk3U26crnW+pfQM8542qrUnkOiBvRgSNtTpnTJ7y C/h//T/IIRLkz2QO4UOYoohq7vi5sEUWrJWHY= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=wJWBNLiO2Ap+o+QNY0ySIzMQ59SNJwpQnW4TV7ekUCEFKyjtCORfxj3ENV8fvQ4dRC MECxvMhAGV6Ju3ijtU0v6Yrxq0QtWBqVtCQMjx1CwExD2sjfTX5luwra+i/NHcJygK5n f6aPlE7W7qLjUGHmOPml3nndhcQvvVS7MbEMU= MIME-Version: 1.0 Received: by 10.204.123.20 with HTTP; Thu, 15 Apr 2010 00:09:14 -0700 (PDT) In-Reply-To: References: <4BC58D10.4050609@lerdorf.com> Date: Thu, 15 Apr 2010 09:09:14 +0200 Received: by 10.204.81.164 with SMTP id x36mr2963257bkk.162.1271315355349; Thu, 15 Apr 2010 00:09:15 -0700 (PDT) Message-ID: To: =?UTF-8?B?SsOpcsO0bWUgTG95ZXQ=?= Cc: =?UTF-8?B?5ruV6Lev6YGl?= , Rasmus Lerdorf , internals@lists.php.net Content-Type: multipart/alternative; boundary=0016e6dd89d92735bd0484412c61 Subject: Re: [PHP-DEV] One suggestion to PHP-FPM From: tyra3l@gmail.com (Ferenc Kovacs) --0016e6dd89d92735bd0484412c61 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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 check th= e > > 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/1882a3b= 2257dcc5c/ea73892cea011541?lnk=3Dgst&q=3Dgaochunhui#ea73892cea011541 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". So one of your lib (for example imagick) leaks memory, on the long run, 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, but 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 > > > > thanks, > > looyao > > > > 2010/4/14 Rasmus Lerdorf > >> > >> On 04/14/2010 02:01 AM, J=C3=A9r=C3=B4me Loyet wrote: > >> > The patch seems good (I didn't test it yet) but I'm curious about th= e > >> > way you check the memory real size: > >> > > >> > + if(zend_memory_usage(1 TSRMLS_CC) > > >> > fpm_global_config.term_on_memory_limit){ > >> > > >> > I don't know much about the zend_memory_usage() function. But does i= t > >> > return the real memory size of the process ? > >> > >> Right, that will only give you the memory allocated by the memory > >> manager, obviously. But, pecl/imagick does seem to use emalloc to > >> allocate the imagick objects. However, if the underlying magickwand > >> library mallocs a bunch of temporary space on its own, this will not g= et > >> picked up. > >> > >> -Rasmus > > > > > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > --0016e6dd89d92735bd0484412c61--