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
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php