Tuning Your Apache Server (2023)

Your Apache configuration settings have a major effect on your Linode’s performance. There are several tools that can be used to further inspect your Apache server’s performance and make informed decisions on how to begin tuning your Apache configurations. This guide will provide an overview of some process monitoring and system resource usage tools that can be used to inspect how Apache is affecting your Linode’s performance. You will also learn about important Apache modules, like the Multi-Processing modules, that will allow you to make use of Apache’s power and flexibility.


The steps in this guide require root privileges. Be sure to run the steps below as root or with the sudo prefix. For more information on privileges see our Users and Groups guide.

There are a variety of tools that can assist in determining if you need to alter resource settings, including the top command and the load-testing program Siege. Linode’s own Longview service can also help with server monitoring. A good place to start is to familiarize yourself with the RAM and CPU usage of your server.

Discover usage statistics with the following variations of the ps command. The ps command is used to generate a report of the running processes on your Linode:

echo [PID] [MEM] [PATH] && ps aux | awk '{print $2, $4, $11}' | sort -k2rn | head -n 20ps -eo pcpu,pid,user,args | sort -k 1 -r | head -20
Apache mod_status

The Apache Status module, mod_status, provides performance information about your server in a detailed status page.

(Video) Apache HTTP Server Performance Tuning

  1. Open your website’s configuration file. This file is located at /etc/apache2/sites-available/hostname.example.com.conf on Debian/Ubuntu systems or /etc/httpd/conf.d/vhost.conf on CentOS/Fedora systems.

  2. Add the following to the <virtual_hosts> block:

    File: /etc/apache2/sites-available/hostname.example.com.conf (Debian/Ubuntu)
    <Location /server-status> SetHandler server-status Order Deny,Allow Deny from all Allow from localhost</Location> 
  3. Apache mod_status also offers an option called ExtendedStatus, which provides additional information about each request made to Apache. To enable ExtendedStatus edit your Apache configuration file and add the following line:

    File: /etc/apache2/apache2.conf (Debian/Ubuntu)
    ExtendedStatus On 

    Enabling ExtendedStatus consumes additional system resources.

  4. Restart Apache:

    • Debian/Ubuntu: systemctl restart apache2
    • CentOS/Fedora:

      (Video) Apache Performance Tuning: Swap Memory

      systemctl restart httpd

  5. To view the generated file, download Lynx, a text-mode web browse:

    • Debian/Ubuntu:

      apt-get install lynx

    • Fedora/CentOS: yum install lynx
  6. Open the file:

    lynx http://localhost/server-status

The Apache2Buddy script, similar to MySQLTuner, reviews your Apache setup, and makes suggestions based on your Apache process memory and overall RAM. Although it is a fairly basic program, that focuses on the MaxClients directive, Apache2Buddy is useful. You can run the script with the following command:

curl -sL https://raw.githubusercontent.com/richardforth/apache2buddy/master/apache2buddy.pl | sudo perl
Multi Processing Modules

Apache version 2.4 offers three Multi Processing Modules (MPM) for managing your settings. Each module creates child processes, but differs in how they handle threads.

Before making any changes to your Apache configuration, be sure to back up the configuration file:

  • On Debian/Ubuntu:

     cp /etc/apache2/apache2.conf ~/apache2.conf.backup
  • On CentOS/Fedora:

     cp /etc/httpd/conf/httpd.conf ~/httpd.conf.backup

The prefork module creates a number of child processes at launch, each child handles only one thread. Since these processes deal solely with one thread at a time, request speed can suffer should there be too many concurrent requests. When this occurs, some requests essentially have to wait in line to be acted upon. To handle this, you can increase the number of child processes that are spawned, however, this increases the amount of RAM being used. Prefork is the safest module, and should be used when using non-thread-safe libraries.


The worker module’s child processes spawn many threads per process with each thread ready to take on new requests. This allows for a greater number of concurrent requests to come in, and in turn, is easier on the server’s RAM usage. Overall, the worker module offers higher performance, but is less secure than the prefork module and cannot be used with modules that are not thread safe.

(Video) Apache Bench - How to Load Test Web Server


The event module is only available on Apache 2.4 and is based off of the worker MPM. Like the worker, it creates multiple threads per child process, with a thread dedicated to KeepAlive connections that are handed down to child threads once the request has been made. This is good for multiple concurrent connections, especially those that are not all active at the same time but make the occasional request. The event MPM functions the same as worker in the event of SSL connections.

Module Values

Once you select your MPM, you will need to change the values inside the configuration. These settings are located in the /etc/apache2/apache2.conf file on Debian/Ubuntu, and the /etc/httpd/conf/httpd.conf file on CentOS/Fedora. Below, is an example configuration for the MPM prefork module:

File: /etc/apache2/apache2.conf (Debian/Ubuntu)
<IfModule mpm_prefork_module> StartServers 4 MinSpareServers 20 MaxSpareServers 40 MaxRequestWorkers 200 MaxConnectionsPerChild 4500</IfModule>

To use the worker or event modules, replace <IfModule mpm_prefork_module> with <IfModule mpm_worker_module> or <IfModule mpm_event_module>, respectively.

Next, you should alter the module settings you added in the previous step. To do this, you should take into consideration what each value does, and how best to change it. It is recommended to make incremental changes to your configuration settings and then monitor the effects.


After making alterations to the Apache configuration file, restart the service.

  • On Debian/Ubuntu:

     sudo systemctl restart apache2
  • On CentOS/Fedora:

     sudo systemctl restart httpd.service

The sections below provide an overview of each MPM module setting.

(Video) Web Server Bottlenecks And Performance Tuning


The StartServers value indicates the number of child processes created at startup, and is dynamically controlled depending on load. There is often little reason to alter this number, unless your server is restarted frequently and contains a large number of requests upon reboot.


Sets the minimum number of idle child processes. If there are fewer processes than the MinSpareServer number, more processes are created at the rate of one per second on Apache 2.2 or lower. With Apache 2.4, this rate increases exponentially starting with 1 and ending with 32 children spawned per second. The benefit of this value is that when a request comes in it can take an idle thread; should a thread not be available, Apache would have to spawn a new child, taking up resources and extending the time it takes for the request to go through. Note, too many idle processes would also have an adverse effect on the server. Tuning this value should only be necessary on very busy sites. It is not recommended to change this value to a high number.


This parameter sets the maximum number of idle child processes. If there are more idle processes than this number, then they are terminated. Unless your website is extremely busy, this number should not be set too high, since even idle processes consume resources.


Previously known as MaxClients (Apache 2.3.13 or lower), this parameter indicates the maximum amount of requests that can be served simultaneously, with any number going past the limit being queued. The size of the queue is based on the ListenBacklog directive. If MaxRequestWorkers is set too low, connections sent to the queue eventually time-out; however, if set too high, it causes the memory to start swapping. If this value is increased past 256, the ServerLimit value must also be increased.

One way to calculate the best value for this is to divide the amount of RAM each Apache process uses by the amount of RAM available, leaving some room for other processes. Use Apache2Buddy to help determine these values, or the commands below.

To determine the RAM each Apache process uses issue the following command. The Resident Set Size (RSS) value displays the RAM that is currently being used by a process, in kilobytes. Replace httpd with apache2 on Debian or Ubuntu systems:

ps -ylC httpd --sort:rss

Divide the number under the RSS column by 1024 to convert it to megabytes.

To get information on memory usage:

free -m

To receive a more detailed view of the resources Apache is using, use the top command.


MaxConnectionsPerChild limits the number of requests a child process handles during its life. Once the limit has been hit, the child process dies. If set to 0, the child process will never expire. The suggested value for this is a few thousand, to prevent memory leakage. Be aware that setting this too low can slow down the system, since creating new processes does take up resources. This setting was named MaxRequestsPerChild in versions lower than Apache 2.3.9.


In the context of the prefork module, the ServerLimit setting configures the maximum value for MaxRequestWorkers for the entire lifetime of the Apache httpd process. If you need to increase MaxRequestWorkers above 256, then increase your ServerLimit to match.

When using the worker and event modules, ServerLimit and ThreadLimit determine the maximum value for MaxRequestWorkers for the duration of the Apache httpd process. Note that if ServerLimit is set to a value higher than needed, unused shared memory will be set aside.


KeepAlive allows connecting clients to use a single TCP connection to make multiple requests, instead of opening a new one for each request. This decreases page load times and lowers CPU use for your web server, at the expense of an increase in your server’s RAM use. A KeepAlive connection will be counted as a single “request” for the MaxConnectionsPerChild.

(Video) Understanding Server Performance Tuning | Boost Server Performance | Devops Tutorial | Edureka

In the past, this setting was often disabled to conserve RAM use, but server resources have become less expensive, and the option is now enabled by default in Apache 2.4. Enabling KeepAlive can significantly benefit your site’s user experience, so be wary of disabling it without testing the effects of doing so. KeepAlive can be enabled or disabled in your web server configuration, or within a Virtual Host block.

More Information

You may wish to consult the following resources for additional informationon this topic. While these are provided in the hope that they will beuseful, please note that we cannot vouch for the accuracy or timeliness ofexternally hosted materials.

This page was originally published on


How to tune Apache server? ›

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.

How to optimize Apache web server? ›

To increase the performance of your Apache web server, you can do the following:
  1. Switch off unnecessary Apache modules to decrease the server resource consumption.
  2. Set up the Apache restart interval to decrease the number of Apache restarts.
  3. Choose the Apache restart type: graceful or normal.

How do I fix common problems with Apache? ›

Troubleshooting tips for Apache
  1. Verify your Apache HTTP Server configuration. ...
  2. Use the latest version of Apache HTTP Server. ...
  3. Apache HTTP Server logs. ...
  4. Use the mod_log_forensic module. ...
  5. Use the mod_whatkilledus module. ...
  6. Check third-party modules. ...
  7. Run Apache HTTP Server as a single process and use debugging tools.

How to optimize Apache web server for maximum concurrent connections? ›

Here are the steps to increase max connections in Apache.
  1. Install MPM module. We need to install MPM Apache module to be able to serve lots of concurrent connections. ...
  2. Increase Max Connections in Apache. Open MPM configuration file: ...
  3. Restart Apache Server. Restart Apache web server to Apply changes.
Jun 30, 2020

How do you tune a server performance? ›

Let's look at the top 10 tips for SQL Server performance tuning
Feb 24, 2020

How do you check whether Apache is properly running or not? ›

Check if Apache is running on Windows

After pressing Ctrl + Shift + Esc, start typing either "httpd.exe" or "apache.exe" and see if they appear on the list. If they do, then Apache is running.

How to reduce CPU usage in Apache? ›

How to fix Apache high CPU usage?
  1. Blocking the suspicious IP address in firewall.
  2. Disabling the problematic plugin or module.
  3. Suspending the user account that is abusing.
  4. Patching and updating vulnerable software.
  5. Tweaking Apache and PHP configuration.
  6. Scanning and removing infected files.
Mar 4, 2017

How do I configure Apache Web sites? ›

How to Configure Multiple Sites with Apache
  1. Step 1: Make a Directory for Each Site. ...
  2. Step 2: Set Folder Permissions. ...
  3. Step 3: Set up an Index Page. ...
  4. Step 4: Copy the Config File for Each Site. ...
  5. Step 5: Edit the Config File for Each Site. ...
  6. Step 6: Enable Your Config File. ...
  7. Step 7: Verify Apache Configurations.
Jul 29, 2020

How do I optimize server response time? ›

Here are seven easy ways to reduce the server response time for your website.
  1. Use Reliable and Fast Web Hosting. Make sure that your hosting provider caters to the needs of your online customers. ...
  2. Use a CDN. ...
  3. Optimize Databases. ...
  4. Keep WordPress Lightweight. ...
  5. Monitor PHP Usage. ...
  6. Configure Caching. ...
  7. Minify Scripts.
Apr 17, 2019

Do people still use Apache? ›

Yes, and right out of the box. Most web hosting companies will default to Apache as the main web server software. Some may offer additional options, but due to the ease of use, popularity, and resources available, most WordPress sites stick with Apache.

How to configure Apache server in Linux? ›

How to Set Up an Apache Web Server on Linux
  1. Step 1: Install Apache Server on Linux. ...
  2. Step 2: Verify Apache Service Status. ...
  3. Step 3: Configure Firewall to Allow Apache Server Access. ...
  4. Step 4: Understand Apache Directories and Files.
Mar 25, 2022

Is Apache still used today? ›

Apache web server is still popular and used by many websites today. It is an open-source web server that is free to use and is highly customizable. It is also very secure and reliable, making it a great choice for many websites.

How do I change Apache settings? ›

Edit the Apache server configuration file
  1. Locate the Apache http-vhosts. ...
  2. Edit the Apache http-vhosts.conf file. ...
  3. Modify the DocumentRoot setting to point to the Build Forge web application. ...
  4. Leave the port as 80 or change it to the port you run the Apache HTTP Server on locally. ...
  5. Modify any other settings in http-vhosts.

How can I make my Apache 100 faster? ›

How To Speed Up Apache Web Server
  1. Use Apache Latest Version. Every Apache version contains performance improvements that make it faster than previous versions. ...
  2. Use Disk based caching. ...
  3. Choose the right MPM module. ...
  4. Use mod_gzip/mod_deflate modules. ...
  5. Do Not set High KeepAliveTimeout.
Jul 8, 2020

How do I find my Apache server configuration? ›

The location of the Apache configuration file

On most systems if you installed Apache with a package manager, or it came preinstalled, the Apache configuration file is located in one of these locations: /etc/apache2/httpd. conf. /etc/apache2/apache2.


1. Tomcat Performance Tuning
(zz TALK)
2. 10 Easy Ways to Tune Your Cassandra Cluster with John Haddad | DataStax Accelerate 2019
3. Tuning your ESC (BLHeli_32) to stop desyncs and improve motor performance in your FPV quadcopter!
(Chris Rosser)
4. Performance Tuning Apache and Passenger SD
(David Bock)
5. Web Server Bottlenecks And Performance Tuning
(Next Day Video)
6. What's New In CommandBox 5 - Tuning Web Server Max Requests
(Ortus Solutions)
Top Articles
Latest Posts
Article information

Author: Msgr. Benton Quitzon

Last Updated: 01/09/2023

Views: 5551

Rating: 4.2 / 5 (43 voted)

Reviews: 82% of readers found this page helpful

Author information

Name: Msgr. Benton Quitzon

Birthday: 2001-08-13

Address: 96487 Kris Cliff, Teresiafurt, WI 95201

Phone: +9418513585781

Job: Senior Designer

Hobby: Calligraphy, Rowing, Vacation, Geocaching, Web surfing, Electronics, Electronics

Introduction: My name is Msgr. Benton Quitzon, I am a comfortable, charming, thankful, happy, adventurous, handsome, precious person who loves writing and wants to share my knowledge and understanding with you.