• Home
  • Archive
  • Tools
  • Contact Us

The Customize Windows

Technology Journal

  • Cloud Computing
  • Computer
  • Digital Photography
  • Windows 7
  • Archive
  • Cloud Computing
  • Virtualization
  • Computer and Internet
  • Digital Photography
  • Android
  • Sysadmin
  • Electronics
  • Big Data
  • Virtualization
  • Downloads
  • Web Development
  • Apple
  • Android
Advertisement
You are here:Home » How to Optimize Apache Keepalive Settings (Ubuntu Server + WordPress)

By Abhishek Ghosh January 26, 2024 10:07 pm Updated on January 26, 2024

How to Optimize Apache Keepalive Settings (Ubuntu Server + WordPress)

Advertisement

In our earlier articles, we have discussed How to Install Apache and PHP on Ubuntu 22.04 Server and What is Keepalive in the Context of Apache Webserver. From the previous articles, we have learned that:

Keepalive is a mechanism in data transmission with the goals of maintaining a network connection and convincing oneself of the accessibility and function of a communication partner. Keepalives are usually specific packets of a network protocol. A keep-alive signal is often sent at predefined intervals. If no response is received after a signal is sent, it is assumed that the connection is lost, or future data is routed through a different path until the connection is restored. A keep-alive signal can also be used to indicate to the Internet infrastructure that the connection should be maintained. So far, we have mentioned the following points:

Advantages of Keepalive

Advertisement

---

How to Optimize Apache Keepalive Settings Ubuntu Server WordPress
  • Reduces latency associated with HTTP transfers
  • Reduces CPU usage while serving different files such as images, stylesheets, javascript files etc

Disadvantages of Keepalive

  • Increases memory usage

 

How to Optimize Apache Keepalive Settings

 

You can test whether Keepalive is working or not by running this command:

Vim
1
curl -Iv https://example.com 2>&1 | grep -i 'connection #0'

If you get:

Vim
1
* Connection #0 to host example.com left intact

That means keepalive is working. You can use some online tools to check keepalive:

Vim
1
2
https://technumero.com/keep-alive-test/
https://www.giftofspeed.com/check-keep-alive/

Coming back to the topic. We are using the mpm_event module. The main configuration file for Apache settings is this one:

Vim
1
/etc/apache2/apache2.conf

Open that file:

Vim
1
nano /etc/apache2/apache2.conf

Search for the phrase keepalive by pressing ctrl + w. This is the default settings:

Vim
1
2
3
4
5
6
...
Timeout 300
KeepAlive On
MaxKeepAliveRequests 100
KeepAliveTimeout 5
...

Usually, this settings is enough good. Open the mpm_event configuration file:

Vim
1
nano /etc/apache2/mods-enabled/mpm_event.conf

For a server with 16GB RAM, you can try this setting:

Vim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
<IfModule mpm_event_module>
    KeepAlive On
    KeepAliveTimeout 5
    MaxKeepAliveRequests 128
 
    ServerLimit 10
    StartServers 4
    ThreadLimit 128
    ThreadsPerChild 128
    MinSpareThreads 256
    MaxSpareThreads 512
    MaxRequestWorkers 1280
    MaxConnectionsPerChild 2048
</IfModule>

Restart Apache after any change:

Vim
1
2
3
sudo apachectl -t
# If syntax is OK
sudo systemctl restart apache2

Keepalive is indirectly related to the other settings. Apache documentation says “When a client uses a Keep-Alive connection, it will be counted as a single “request” for the MaxConnectionsPerChild directive, regardless of how many requests are sent using the connection.” In our case, it is 2048.

Whenever an Apache server is started, it will start the child processes which are determined by the StartServers parameter. In our case, it is 4.

Then each process will start 128 threads determined by the ThreadsPerChild parameter so this means 4 processes can service 512 concurrent connections/clients i.e. 128×4=512.

Now if more concurrent users come, then another child process will start, which can service another 128 users. But how many child processes can be started is controlled by the ServerLimit parameter, this means that in the configuration above, we can have 10 child processes in total, with each child process can handle 128 threads, in total handling 10×128=1280 concurrent users. It is huge enough. We have to keep so high because of legitimate bots & crawlers. If we increase too much, there is a chance of abuse, apart from resource limit.

But if the number defined in MaxRequestWorkers (previously it was MaxClients) is less than 200, then this means that after 10 child processes, no extra process will start since we have defined an upper cap of MaxRequestWorkers. In this case, we may need to also increase ServerLimit i.e. MaxRequestWorkers /ThreadsPerChild. As you can see, we have done the math for you.

Related Apache documentation: https://httpd.apache.org/docs/2.4/mod/core.html#keepalive

Facebook Twitter Pinterest

Abhishek Ghosh

About Abhishek Ghosh

Abhishek Ghosh is a Businessman, Surgeon, Author and Blogger. You can keep touch with him on Twitter - @AbhishekCTRL.

Here’s what we’ve got for you which might like :

Articles Related to How to Optimize Apache Keepalive Settings (Ubuntu Server + WordPress)

  • Nginx WordPress Installation Guide (All Steps)

    This is a Full Nginx WordPress Installation Guide With All the Steps, Including Some Optimization and Setup Which is Compatible With WordPress DOT ORG Example Settings For Nginx.

  • WordPress & PHP : Different AdSense Units on Mobile Devices

    Here is How To Serve Different AdSense Units on Mobile Devices on WordPress With PHP. WordPress Has Function Which Can Be Used In Free Way.

  • Changing Data With cURL for OpenStack Swift (HP Cloud CDN)

    Changing Data With cURL For Object is Quite Easy in OpenStack Swift. Here Are Examples With HP Cloud CDN To Make it Clear. Official Examples Are Bad.

  • Steps To Install Nginx Plus on Ubuntu Server (HP Cloud)

    Here Are the Steps To Install Nginx Plus on Ubuntu Server Running on HP Cloud. Nginx Plus is the Paid Version of Nginx with Extra Features.

performing a search on this website can help you. Also, we have YouTube Videos.

Take The Conversation Further ...

We'd love to know your thoughts on this article.
Meet the Author over on Twitter to join the conversation right now!

If you want to Advertise on our Article or want a Sponsored Article, you are invited to Contact us.

Contact Us

Subscribe To Our Free Newsletter

Get new posts by email:

Please Confirm the Subscription When Approval Email Will Arrive in Your Email Inbox as Second Step.

Search this website…

 

vpsdime

Popular Articles

Our Homepage is best place to find popular articles!

Here Are Some Good to Read Articles :

  • Cloud Computing Service Models
  • What is Cloud Computing?
  • Cloud Computing and Social Networks in Mobile Space
  • ARM Processor Architecture
  • What Camera Mode to Choose
  • Indispensable MySQL queries for custom fields in WordPress
  • Windows 7 Speech Recognition Scripting Related Tutorials

Social Networks

  • Pinterest (24.3K Followers)
  • Twitter (5.8k Followers)
  • Facebook (5.7k Followers)
  • LinkedIn (3.7k Followers)
  • YouTube (1.3k Followers)
  • GitHub (Repository)
  • GitHub (Gists)
Looking to publish sponsored article on our website?

Contact us

Recent Posts

  • Cloud-Powered Play: How Streaming Tech is Reshaping Online GamesSeptember 3, 2025
  • How to Use Transcribed Texts for MarketingAugust 14, 2025
  • nRF7002 DK vs ESP32 – A Technical Comparison for Wireless IoT DesignJune 18, 2025
  • Principles of Non-Invasive Blood Glucose Measurement By Near Infrared (NIR)June 11, 2025
  • Continuous Non-Invasive Blood Glucose Measurements: Present Situation (May 2025)May 23, 2025
PC users can consult Corrine Chorney for Security.

Want to know more about us?

Read Notability and Mentions & Our Setup.

Copyright © 2026 - The Customize Windows | dESIGNed by The Customize Windows

Copyright  · Privacy Policy  · Advertising Policy  · Terms of Service  · Refund Policy