J. Peng wrote:
>
> Apache with prefork mode can share the memory? Sorry I didn't know it.
> Sharing memory between multi-processes need extra programming, I don't
> know apache has done it already.


Both prefork and worker models share memory. fork() takes all of your
pages and marks them "copy on write". This means; no-touchie, share nice.
Don't confuse this with shared, writeable pages.

Once you do write to any byte of a common page (even assigning the same
value and not actually anything), the kernel makes you up your own private
copy. Do that in every fork()ed child, and it hurts. This is why the
process and conf pools of httpd should never be touched by a sane module
from the child_init hook, onwards.

But you won't notice the sharing as much with worker model, since there
might be only 10 processes sharing memory to support 250 children, instead
of 250 children all sharing that same config. Although worker starts out
25 times more compact, so the net win from fork()+threading is roughly
equivalent ;-)