Thanks to its reliable features, open-source accessibility and community support, Apache is the internet’s favourite web server.

While Apache regularly delivers excellent performance for a wide variety of websites and applications, higher traffic volumes can impact loading times, potentially resulting in frustrated users.

For this reason, it’s always a good idea to fully optimise your Apache web server to deliver the best possible performance and a great user experience.

So what can you do to make sure Apache is firing on all cylinders?

Keep Apache up to date

As with all your software, you’ll want to keep Apache up to date to benefit from the latest performance-enhancing features, as well as all the usual security patches and bug fixes.

If you’re running CentOS or Ubuntu on virtual servers on our CloudNX platform, you can check for the latest software and update your installed packages with the following commands:

  • CentOS 7: sudo yum update
  • Ubuntu 16.04: sudo apt-get update

Use alternative tools

It’s possible to replicate the functionality of certain modules using alternative solutions. Depending on your server setup and the resources available, these can offer better performance than the standard modules. If suitable for your application, consider using alternative tools such as:

Optimise your Apache settings

Several Apache settings can be tweaked to optimise web server performance. Three of the most important settings are MaxKeepAliveRequests, KeepAlive, and KeepAliveTimeout:

  • MaxKeepAliveRequests sets the maximum number of requests that are accepted per connection. In performance terms, higher is generally better, but only up to a point. The recommended value is 500.
  • KeepAlive sets whether or not Apache will accept more than one request per connection. Note that by default this is set to off on CentOS 7. For increased performance on high-traffic applications, setting this to on is recommended.
  • KeepAliveTimeout sets the amount of time Apache will wait for a new request before closing the connection. For optimum performance, this should be kept low, ideally between one and five seconds.

Choose the right Multi-Processing Module

Multi-Processing Modules (MPMs) give Apache the ability to handle requests in a variety of ways, allowing a more customised setup reflecting the specific needs of a particular application.

To ensure you’re getting the best performance, understanding the strengths of each MPM and choosing the right one is vital:

  • prefork enables multiple processes without threading – in other words, each process handles one connection (threading allows more than one per process). While threading can be beneficial to performance, prefork is required for use alongside certain modules that can’t use threading, e.g. mod_php.
  • worker offers threading, with several threads per process, and each thread able to handle a connection. worker is a good choice for high-traffic websites and applications, but often you may find that using event makes more sense (see below).
  • event is usually the default MPM. Like worker, it can create multiple threads per process, but it can also handle KeepAlive or idle connections with a single thread, freeing up additional resources. For most applications, this makes event the best choice for maximising performance.

Ultimately, the most effective Apache tuning measures will always depend on the specifics of your application. To fully optimise the performance your Apache web server, you need to consider the server resources available to you and the demands placed on them, both in terms of web traffic and the functionality of your application.

On the CloudNX cloud hosting platform, you can spin up powerful virtual machines with Apache installed by default on a standard Linux installation. Scale dedicated resources on demand, with complete control to configure every aspect of your cloud servers, plus the reliability of UK data centres and 27/7 UK-based support.