How To Speed Up Apache Web Server

Last updated on August 10th, 2020 at 03:05 am

It is important to optimize Apache web server to maximize server performance. Here are 5 Apache tuning tips to speed up Apache web server.

 

How To Speed Up Apache Web Server

Here are top 5 ways to speed up Apache web server.

 

1. Use Apache Latest Version

Every Apache version contains performance improvements that make it faster than previous versions. So make sure you are running the latest version of Apache web server.

As of March 26, 2020  Apache’s latest version is 2.4.43

You can check your Apache version using the following command

# httpd -v [On RedHat/CentOS based systems]
# apache2 –v [On Debian/Ubuntu based systems]

Here are the steps to upgrade Apache version on:

1. Ubuntu / Debian Systems

2. Redhat / CentOS systems

 

2. Use Disk based caching

Apache allows caching in disk as well as on memory. It is advisable to use disk-based caching instead of memory-based caching since memory caching does not share cache among Apache processes resulting in higher memory usage and poor performance.

Here are the steps to enable cache in Apache.

 

3. Choose the right MPM module

Apache offers a Multi-Processing Module (MPM) that allows you to handle large number of requests and concurrent connections.

However, there are 3 different multi-processing module prefork, worker, and event available. So pick the one that fits your requirements.

  • preforkprefork uses multiple processes without threading, each process handles one connection.
  • workerworker uses multiple threads per child process, with each thread handling one connection at a time.
  • event – it is the default MPM module in most Apache installations similar to worker but uses KeepAlive connections to be handled by one thread, saving memory.

You can check your MPM module using the following command

# httpd -V

Here are the steps to configure MPM module in Apache.

 

4. Use mod_gzip/mod_deflate modules

mod_gzip and mod_deflate modules make Apache gzip all content before they are sent to client browser, which are automatically unzipped by web browsers.

This will reduce number of file transfers and improve user experience.

 

5. Do Not set High KeepAliveTimeout

KeepAliveTimeout directive defines the number of seconds Apache should wait for a new request from an existing connection before it closes that connection. It is advisable to keep this value between 1 and 5.

If you keep this value high then your Apache server may end up with more pending requests than available children processes.

 

Hopefully, the above Apache performance tuning tips will help you speed up Apache web server.

Ubiq makes it easy to visualize data in minutes, and monitor in real-time dashboards. Try it Today!