Learn how to install and use Apache Tomcat on CentOS 7. Apache Tomcat is a Java Servlet container developed by Apache to which allows you to deploy Java servlets and JSPs. Apache Tomcat also functions as a web server, which is able to support small to medium-sized websites. This tutorial also covers how to install and use the Tomcat Web Admin Manager, which allows you to manage Tomcat and virtual...
The Apache web server is the most popular web server due to its power and versatility. However, as traffic to your website scales, Apache performance can become a significant issue for your visitors. Learn three easy ways to improve the performance of your Apache web server.
- A Cloud Server with Linux (Ubuntu 16.04 or CentOS 7)
- Apache web server installed and running
Apache is installed and running on a Standard Linux installation by default. If your server was created with a Minimal installation, you will need to install and configure Apache before you proceed.
As with all software on your server, it is important to keep Apache up to date. Newer versions of Apache include bug fixes and performance improvements which can greatly increase the security and performance 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 Processing 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 processing on Apache, which can slow down website response times across the board.
To improve Apache's performance, consider migrating to these alternative solutions instead:
Dedicated Hosting - Powerful web hosting with dedicated hardware
Fast and scalable, starting from $55/month!
Change Apache's MaxKeepAliveRequests, KeepAlive, and KeepAliveTimeout Settings
Three important Apache settings which can be tuned for improved performance are the MaxKeepAliveRequests, KeepAlive, and KeepAliveTimeout.
MaxKeepAliveRequests sets the maximum number of requests to accept per connection. The higher this number, the better the performance of the server, up to a point. The recommended value is 500.
KeepAlive sets whether Apache will allow more than one request per connection. This is set to Off by default on CentOS 7. High-traffic servers can see a significant performance improvement by changing this setting to On.
KeepAliveTimeout sets the number of seconds Apache will wait for a new request from a connection before it closes the connection. This number should be kept low. The recommended value is between 1 and 5.
To change these settings, open the main Apache configuration 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, customizing the values to your preference:
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