Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:21769 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 50804 invoked by uid 1010); 2 Feb 2006 20:17:21 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 50789 invoked from network); 2 Feb 2006 20:17:21 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 2 Feb 2006 20:17:21 -0000 X-Host-Fingerprint: 204.11.219.139 lerdorf.com Linux 2.4/2.6 Received: from ([204.11.219.139:59001] helo=colo.lerdorf.com) by pb1.pair.com (ecelerity 2.0 beta r(6323M)) with SMTP id DD/F3-20872-0D862E34 for ; Thu, 02 Feb 2006 15:17:20 -0500 Received: from [192.168.150.3] ([203.98.22.198]) (authenticated bits=0) by colo.lerdorf.com (8.13.5/8.13.5/Debian-3) with ESMTP id k12KHCgK015514 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Thu, 2 Feb 2006 12:17:14 -0800 Message-ID: <43E268CA.3020106@lerdorf.com> Date: Fri, 03 Feb 2006 09:17:14 +1300 User-Agent: Thunderbird 1.5 (Macintosh/20051201) MIME-Version: 1.0 To: Brian Moon CC: php internals References: <43E25FEC.3020808@dealnews.com> In-Reply-To: <43E25FEC.3020808@dealnews.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: ClamAV 0.88/1270/Thu Feb 2 04:47:37 2006 on colo X-Virus-Status: Clean Subject: Re: [PHP-DEV] PHP, Apache 2, memory and APC From: rasmus@lerdorf.com (Rasmus Lerdorf) Brian Moon wrote: > I have some questions about the Apache 2 SAPI. We had been using > apache_child_terminate to control memory usage with Apache 1.3. This > function is not available with the Apache 2 SAPI. Is this function just > not offered in the Apache 2 API? If it is offered and there is some > gotcha or simply work to be done, I would be happy to roll up my > sleeves, dust off my C hat and submit a patch. I just need a push in > the right direction. I can't really find an Apache 2 SAPI API reference > anywhere. > > Because we can not use this function, we decided to try out the worker > MPM to help our memory woes. So far, we have had great success with it. > Our limited extension list appears to have no problems. The memory > usage on our web servers is down about 15% now. That makes very little sense. An individual Apache process will use the same amount of memory whether it is an Apache1 process or an Apache2 Worker process. It probably uses more under Apache2 ZTS actually (and it runs slower). The only difference is that the threads within the Apache2 ZTS process will re-use each others' memory while under Apache1 the memory will only be reused by requests to the same process. Trying to hand it back to the OS via an sbrk or something is usually rather redundant since another request will come along and allocate that same amount again. If you are running out of system memory the only realistic recourse is to lower the number of concurrent processes. I tend to never run more than about 50 per machine, depending on the size of the machine. Trying to run more doesn't win you anything. You are better off serving less concurrent requests faster on each of your machines behind your load balancer. > However, this meant we can not use APC. Are there plans to make APC > work with ZTS? I know APC is not developed by the PHP group, but I also > know Rasmus is involved and I hoped this would find him the easiest. I have no plans to work on ZTS stuff. Work has been done on it in the past though and I know it works in ZTS mode at least under Windows. > Speaking of those memory woes, I know there is a lot of confusion about > that problem with PHP. Can one of the core guys explain why the PHP > memory manager can't give the memory back like a simple emalloc can? emalloc is the PHP memory manager. Did you mean malloc? Standard malloc()/free() doesn't give memory back to the system. If your process mallocs 100M and then frees that memory, your process still hangs onto that 100M until it exits (with some caveats/exceptions on that, but generically that is how UNIX works). -Rasmus