On Wed, Dec 15, 2010 at 5:46 PM, Julien Pauli <jpa...@php.net> wrote:

> Well, I can't answer precisely about kernel fork() implementation and
> possible copy on write mechanisms. May vary across systems.
> Someone here could answer I suppose.
>
> 'top' on httpd process with a prefork mpm gives each child process
> memory as a whole XxxMb process, but I don't know what kind of memory
> top sees (and other tools such as 'free').
> Anyway, even with a good kernel process COW, threaded systems tend to
> be less memory hungry than equivalent forked systems.
>
> APC uses shared segments with differents tools such as shm, mmap
> etc... (chosen at compile time).
>
> J.Pauli
>
>
http://www.kernel.org/doc/man-pages/online/pages/man2/fork.2.html
<http://www.kernel.org/doc/man-pages/online/pages/man2/fork.2.html>

       Under Linux, *fork*() is implemented using copy-on-write pages,
so the only
       penalty that it incurs is the time and memory required to duplicate the
       parent's page tables, and to create a unique task structure for
the child.


Imo if you create the threads or worker processes beforehand, there isn't
much difference between the two method in performance POV.

good slides on the fork vs threads:
http://samba.org/~tridge/talks/threads.pdf

so for me I would go with the prefork, because it's easier to maintain
(non-thread safe apps are hard to debug :/)

Tyrael

Reply via email to