Apache tweaks for production.

*Note: Incomplete

Here are some of the options I have found useful / acceptable in a production apache setup, please note I make no guarantee that these settings will work for your setup. that said enjoy your tweaking.

When every byte counts...

Cleaning all comments from apaches configuration files.
sed '/^\#/d' /etc/apache2/apache2.conf > /tmp/production_apache2.conf

When you are sure its ok to replace it.
mv /tmp/production_apache2.conf /etc/apache2/apache2.conf

Enable Compresion

Enabling compression has well documented advantages like the reduced download time from file size decrease of up to 30%, which has a knock on effect of reducing active connections as well as saving precious bandwidth.

There are an array of options for enabling compression with apache, you can enable it on virtual hosts individually or system wide, you can enable it for specific mime types . Some static files like images and zip files have already been compressed and will unnecessarily use CPU cycles, to stop this we will only allow html, xhtml, xml files to be compressed if the connecting clients browser supports it, if not it will send all files uncompressed.

AddOutputFilterByType DEFLATE text/html text/plain text/xml
DeflateFilterNote Input input_info
DeflateFilterNote Output output_info
DeflateFilterNote Ratio ratio_info
#LogFormat '"%r" %{output_info}n/%{input_info}n (%{ratio_info}n%%)' defl$
#CustomLog /var/www/log/apache/deflate_log deflate

Other Considerations

If you have thousands of static media like images movies you can benefit substantially by having a second light weight web server like lighttpd serve these files, some frameworks even recommend this method.

I have also documented this type of setup using lighttpd to proxy dynamic page requests to apache and serve media files with out the inherent overhead of apache and associated modules.

Comments

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <p> <br> <b> <i>
  • Lines and paragraphs break automatically.

More information about formatting options