Back to Top

How to Configure KeepAlive Directive in Apache

keepalive directive in apache

The keepalive directive in Apache is used to keeps the HTTP connection open instead of opening a new connection with each and every new request. This is also known as persistence connection which is the feature of HTTP/1.1 for long-lived HTTP connection.Here you will get the exact idea how to configure keepalive directive in apache.

Let’s see the syntax of KeepAlive directive:

SYNTAX:

KeepAlive specifies whether persistent connections should be On or Off. Default value for KeepAlive is On so it is enabled by default and make connections keep open.You can disable persistent connection setting as Off.

Note: A KeepAlive connection with HTTP/1.0 can only be used if length of the content is known in advance.

Basically, KeepAlive directive keeps each HTTP connection open to avoid unnecessary delay. This is useful when client tries to make a several connection to the web server so the KeepAlive Directive allows client to make the different connection for every request. When you have lots of traffic on your website, this feature will create a problem in some cases because web server will have lots of unused open connection.

To Solve this issue when you have more traffic.You can set the KeepAliveTimeout to cache HTTP connection and to avoid waiting too long for the next request.

Let’s understand about the KeepAliveTimeout.

SYNTAX:

KeepAliveTimeout directive sets the number of seconds to wait for the next request and once the request has been received, the TimeOut directive applies.

TimeOut directive in Apache

Here is the syntax for TimeOut directive.

SYNTAX:

Default seconds for TimeOut is 1200.You can set the maximum time so that the server will wait for the receipt of a request. TimeOut directive useful to downloads of large files over slow connections.

Here is the line of code you can set for KeepAlive and KeepAliveTimeout directive.

As per above code, the web server will cache that HTTP connection for the specific time which is here 5 seconds and it will not open unused and unrequired connections.

To Limit the number of connections

MaxKeepAliveRequests directive is used for a maximum number of KeepAlive requests per connection and it will have 0 for infinite.Let’s set the number of requests to perform a Persistent Connection.

SYNTAX:

Let’s see the example of MaxKeepAliveRequests directive:

If this value is set to 0 then it will be considered as infinite requests.

Note: I recommend to set the higher value of this Directive for maximum server performance.

That’s it with KeepAlive directive.It is good to enable the KeepAlive Directive with KeepAliveTimeout.

Share:
Share on Facebook1

Share on LinkedIn0Tweet about this on TwitterShare on Google+0Buffer this pageDigg thisShare on Reddit0

Leave a Reply

Your email address will not be published. Required fields are marked *

Most Popular Posts

Static Methods and Properties in PHP

Posted on 5 years ago

Bhumi

Really! PHP touches the 200 Million Mark

Posted on 4 years ago

John Pitt

How to add ColorDots in FullCalender?

Posted on 2 years ago

Bhumi

How to call Remote URL in jQuery Ajax?

Posted on 3 years ago

Bhumi

How to check user is logged in Modx

Posted on 4 years ago

Bhumi

HTML5 Geolocation API with Example

Updated 17 years ago

Bhumi

Overview of Views in MySQL

Updated 17 years ago

Bhumi

What is Closure in JavaScript?

Updated 17 years ago

Bhumi

How to use JavaScript Promise API?

Updated 17 years ago

Bhumi

Type Hinting Callable Functions in PHP

Updated 17 years ago

Bhumi

The Reader’s Poll – June 2015

Posted on 1 year ago

Bhumi

The Reader’s Poll – August 2014

Posted on 2 years ago

Bhumi

The Reader’s Poll – June 2014

Posted on 2 years ago

Bhumi

The Readers’ Poll – May 2014

Posted on 3 years ago

Bhumi

The Readers’ Poll – August 2013

Posted on 3 years ago

Bhumi