Improving the performance of a website for a VPS: Apache

When you run a website on a VPS, making any sort of improvements are helpful. This holds true for large servers as well. So another area you can improve is your web server. It’s really not that hard to tweak, if you know what to look for.

One of the easiest things you can do, if your modules are dynamically loaded, is to comment them out. When ever a module is active, it takes up some memory in every instance of Apache that runs. When I get more time, I will give a more thorough analysis as to which modules are safe to disable based on your needs, but for right now I’ll give you some general guidelines of what to look for. If you find that a something doesn’t work when you have disabled a module, turn it back on.

Modules:

Disable the modules you know you don’t use. It’s simple to just comment them out.

  • userdir_module: this module supports user’s with a website folder. If you’ve ever seen something like http://www.example.com/~chris/  that’s a userdir. If you have a development environment, this is usefully to leave this on if you use it. If not, disable it.
  • cgi_module: this module does the handling for /cgi-bin/. If you still use cgi-bin for any of your scripts, leave it on, otherwise, disable it.
  • Any module that starts with proxy. If you use any of the proxy modules, leave them on, other wise disable them.
  • There are a number of modules that deal with authentication that you can disable, but there are one or two modules you need in that group because they provide code to some other sections of apache that if you were to disable them, you will notice some issues.
  • dav_module and dave_fs_module: Unless you use web dav for editing content on your website, disable them.
  • Depending on how you installed apache, it will install modules for specific programming languages like PHP, Perl, Python, and other things. If you don’t need those things, disable it.

I’ve used this methods for years, and have found a great reduction in memory usage. Some cases shaving off 2-5MB per process.