Hacker News .hnnew | past | comments | ask | show | jobs | submitlogin

I hear this a lot about Apache and there's one thing I'm not sure a lot of people understand... it's SHARED memory in most cases. While it spawns several processes (depending on which worker method), it's not as awful as it looks at first glance.

Apache, and specifically mod_php, doesn't have that level of control over memory usage (mod_perl (and, incidentally, mod_python) has deeper integration with Apache to encourage, with the right configuration, more of the memory to be shared between processes, but it's still not that great). The Apache parent process, primarily exists to do process, signal, and socket management, it's not really possible to do a lot of application level (pre)processing before subprocesses are forked off, which is what would be required to share a significant portion of the address space.

If you have a .php file run via mod_php that looks like this:

    $x="";
    for ($a=0;$a<(1024*1024*100);$a++) {
      $x.="1";
    }
This will produce 100MB of non-shared memory in a child process, when the request is made and serviced by that child. And, because of the way requests are dispatched to children, at a low request rate the same child could end up serving all (or a majority of) requests. This unbalances the memory usage between processes.

A quick google search finds a nitty gritty page that might help - http://foertsch.name/ModPerl-Tricks/Measuring-memory-consump.... there's probably better examples.

That is a great link in general for how shared memory and COW works.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: