The Apache web server is the most popular web server due to its power and ver­sat­il­ity. However, as traffic to your website scales, Apache per­form­ance can become a sig­ni­fic­ant issue for your visitors. Learn three easy ways to improve the per­form­ance of your Apache web server.

Cheap domain names – buy yours now
  • Free website pro­tec­tion with SSL Wildcard included
  • Free private re­gis­tra­tion for greater privacy
  • Free Domain Connect for easy DNS setup

Re­quire­ments

  • A Cloud Server with Linux (Ubuntu 16.04 or CentOS 7)
  • Apache web server installed and running
Note

Apache is installed and running on a Standard Linux in­stall­a­tion by default. If your server was created with a Minimal in­stall­a­tion, you will need to install and configure Apache before you proceed.

Update Apache

As with all software on your server, it is important to keep Apache up to date. Newer versions of Apache include bug fixes and per­form­ance im­prove­ments which can greatly increase the security and per­form­ance of your web server.

You can check for newer software versions and update installed packages with the command:

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

Remove the burden of pro­cessing code from Apache

Apache modules provide a quick and easy solution to process the code needed to operate your website. Some of the most popular modules are mod_php for PHP, mod_rails for Ruby on Rails, and mod_python for Python.

However, these modules come with a price: they put the burden of code pro­cessing on Apache, which can slow down website response times across the board.

To improve Apache's per­form­ance, consider migrating to these al­tern­at­ive solutions instead:

Change Apache's Max­KeepAlive­Requests, KeepAlive, and KeepAliv­e­Timeout settings

Three important Apache settings which can be tuned for improved per­form­ance are the Max­KeepAlive­Requests, KeepAlive, and KeepAliv­e­Timeout.

Max­KeepAlive­Requests sets the maximum number of requests to accept per con­nec­tion. The higher this number, the better the per­form­ance of the server, up to a point. The re­com­men­ded value is 500.

KeepAlive sets whether Apache will allow more than one request per con­nec­tion. This is set to Off by default on CentOS 7. High-traffic servers can see a sig­ni­fic­ant per­form­ance im­prove­ment by changing this setting to On.

KeepAliv­e­Timeout sets the number of seconds Apache will wait for a new request from a con­nec­tion before it closes the con­nec­tion. This number should be kept low. The re­com­men­ded value is between 1 and 5.

To change these settings, open the main Apache con­fig­ur­a­tion file for editing:

  • CentOS 7:sudo nano /etc/httpd/conf/httpd.conf
  • Ubuntu 16.04:sudo nano /etc/apache2/apache2.conf

Add the following lines to this file, cus­tom­iz­ing the values to your pref­er­ence:

MaxKeepAliveRequests 500
KeepAlive On
KeepAliveTimeout 3

Save and exit the file. Then restart Apache for the changes to take effect:

  • CentOS 7:sudo systemctl restart httpd
  • Utu 16.04:sudo systemctl restart apache2
Go to Main Menu