Skip to content

Putting Apache on a diet - how to get a lean configuration, Part 1

In this article I'm going to go over some of the details of how Apache works, and uses memory. As you will see, the apache processes that serve requests will grow to include the amount of memory they need for a particular request, and they will still be using that memory, even when they are serving something simple like a .css file or an image.

For this reason, the first limitation you are likely to encounter running Apache is a limitation on memory. I will explore this topic and show you how you can do the same.

The first thing need to determine about Apache is what mode it is running in. If your plan is to use Apache with php via mod_apache, then the prevailing wisdom for many years has been that there may be library extensions in PHP that are not thread safe. For this reason, people have tended to avoid running Apache as a threaded server, for fear that scripts may randomly die producing the dreaded 500 Internal server error pages we all know and love.

This fear may be overstated depending on the nature of your php code, but the defaults for apache packages I've seen, seem almost always to be using the prefork worker.

Prefork vs Worker?

So the first question you might be asking yourself is, which mode is my current apache server running in? There is a simple safe way to determine this -- run the httpd(apache) program with a specific command line switch. There are programs like which and whereis that might help you locate it, if you don't know where it is.


whereis httpd
 


CODE:
httpd: /usr/sbin/httpd.worker /usr/sbin/httpd /usr/sbin/httpd.event /etc/httpd /usr/share/man/man8/httpd.8.gz

So let's run the /usr/sbin/httpd with the -h for help and see what happens:




Continue reading "Putting Apache on a diet - how to get a lean configuration, Part 1"