Keep Alive is a useful feature that allows your web server to maintain persistent TCP/IP connections with its client web browsers. This not only reduces server load but also improves website performance. If you have not enabled Keep Alive in Apache web server, follow these steps. Here we will look at how to check Keep Alive in Apache.
How to Check Keep Alive in Apache
Here are the steps to check Keep Alive in Apache. We will use the Apache bench tool (ab) to send 500 requests with a concurrency of 5 workers, with keep alive option (-k option below), to your domain (www.example.com).
Open a terminal window, or SSH into your Linux system. Simply run the following command to send 500 requests as described above, to your domain.
ab -n 500 -c 5 -k http://www.example.com/
the ‘k’ option is used to specify keep alive option
Open another terminal session, and run the following command
This will display all the top processes running in your system. If you find 5 workers are consistently serving requests then the workers are serving requests with keep alive.
Repeat the above process without ‘-k’ option to see the difference. You will find a lot more workers are processing your requests, thereby consuming more server resources.