Recently I’ve been fighting with memory consumption on my server and have been looking for ways that I can reduce the overall load. After some research I found that Apache opens up a file descriptor for each VHosts log file, and keeps this descriptor open all the time. So when I had a bunch of sites that I didn’t mind if their log files were combined, I did some work by using the vhost_combined logging format, which groups a set of vhosts into a single log file.

I verified that first, my /etc/apache2/apache2.conf file had a CustomLog entry for vhost_combined:

Once this was confirmed I went into each of the config files in the sites-available directory and modified a single line:

Notice that I added that ‘vhost_combined’ to the end of this line, meaning that it will use the log format from above and for each vhost assigned to use this log file, only keep 1 file descriptor open instead of 6.

So far I’ve actually noticed a quicker response from my webserver as well as lower memory usage. Hopefully this helps you out as well!

If you’re searching for a hosting provider, I recommend ChunkHost. They have great uptime, a very responsive support staff, and their prices are hard to beat. See my review of ChunkHost.

Post Promoter Pro

Posted by Chris Klosowski

Hi, I'm Chris Klosowski. Currently I am a Lead Developer of Easy Digital Downloads, where we build the easiest way to sell digital products with WordPress. I am also the person behind Post Promoter Pro, the most effective way to promote your WordPress Content.

4 Comments

  1. Good post Chris! Viva Arizona, thanx from Brussels – Belgium.

    They key has been the LogFormat line for vhost_combined in the apache2.conf file

    Now I can keep my virtualhosts in each site-available. Cheers!

    Reply

  2. i am having the same problem but when i add your logformat code into my apache config apache wont start

    Reply

    1. @rater,

      Do you have a specific error that would show up in your /var/log/messages or Apache logs?

      I’ve moved to a different configuration since this original post, but if you have specific error messages that might help you discover why this isn’t working for you.

      Reply

  3. Thank you. Helped me.

    Reply

Leave a reply

Your email address will not be published. Required fields are marked *