You're viewing Apigee Edge documentation.
Go to the
Apigee X documentation. info
This document explains how to configure the keep alive timeout for the Apigee Edge Message Processors.
The keep alive timeout on the Message Processor allows a single TCP connection to send and receive multiple HTTP requests/responses from/to the backend server, instead of opening a new connection for every request/response pair.
The default value of the keep alive timeout property on the Message Processor is
60
seconds. This timeout period is applicable to the backend servers configured
in the target endpoint configuration and in the ServiceCallout
policy of your
API proxy.
The keep alive timeout for Message Processors can be increased or decreased from the default value
of 60
seconds based on your needs. It can be configured in the following ways:
- In the API proxy
- In the target endpoint
- In the
ServiceCallout
policy
- On the Message Processor
The following properties control the keep alive timeout on the Message Processors:
Property name | Location | Description |
---|---|---|
keepalive.timeout.millis |
API proxy:
|
This is the maximum idle time for which the Message Processor allows a single TCP connection to send and receive multiple HTTP requests/responses, instead of opening a new connection for every request/response pair. By default, this property takes the value set for the
If this property is modified with a new timeout value for the target server used in the
target endpoint or the |
HTTPClient.keepalive.timeout.millis |
Message Processor |
This is the maximum idle time for which the Message Processor allows a single TCP connection to send and receive multiple HTTP requests/responses, instead of opening a new connection for every request/response pair. This property is used for all the API proxies running on this Message Processor. The default value of this property is You can either modify this property as explained in
Configuring keep alive timeout on Message Processors
below, or you can overwrite this value by setting the |
Before you begin
Before you use the steps in this document, be sure you understand the following topics:
- If you aren’t familiar with keep alive timeout, see the
keepalive.timeout.millis
property description in TargetEndpoint Transport Property Specification. - If you aren’t familiar with configuring properties for Edge on Private Cloud, read How to configure Edge.
Configuring keep alive timeout in API proxy
The keep alive timeout can be configured in the API proxy in the following places:
- Target endpoint
ServiceCallout
policy
Configuring keep alive timeout in target endpoint of API proxy
This section explains how to configure keep alive timeout in the target endpoint of your
API proxy. The keep alive timeout can be configured through the property
keepalive.timeout.millis
, which represents the keep alive timeout value in
milliseconds.
- In the Edge UI, select the specific API proxy in which you would like to configure the new keep alive timeout value.
- Select the specific target endpoint that you want to modify.
-
Add the property
keepalive.timeout.millis
with an appropriate value under the<HTTPTargetConnection>
element in theTargetEndpoint
configuration.For example, to change the keep alive Timeout to
30
seconds, add the following block of code:<Properties> <Property name="keepalive.timeout.millis">30000</Property> </Properties>
Since the
keepalive.timeout.millis
property is in milliseconds, the value for30
seconds is30000
.The following examples show how to configure the keep alive timeout in the target endpoint configuration of your API proxy:
Example target endpoint configuration using URL for backend server
<TargetEndpoint name="default"> <HTTPTargetConnection> <URL>https://mocktarget.apigee.net/json</URL> <Properties> <Property name="keepalive.timeout.millis">30000</Property> </Properties> </HTTPTargetConnection> </TargetEndpoint>
Example target endpoint configuration using target server
<TargetEndpoint name="default"> <HTTPTargetConnection> <LoadBalancer> <Server name="target1" /> <Server name="target2" /> </LoadBalancer> <Properties> <Property name="keepalive.timeout.millis">30000</Property> </Properties> <Path>/test</Path> </HTTPTargetConnection> </TargetEndpoint>
- Save the changes made to your API proxy.
Configuring keep alive timeout in ServiceCallout policy of API proxy
This section explains how to configure the keep alive timeout in the
ServiceCallout
policy of your API proxy. The keep alive timeout can be
configured through the keepalive.timeout.millis
property, which represents
the keep alive timeout value in milliseconds.
To configure the keep alive timeout in the ServiceCallout
policy using the
keepalive.timeout.millis
property:
- In the Edge UI, select the specific API proxy in which you would like to configure the new
keep alive timeout value for the
ServiceCallout
policy. - Select the specific
ServiceCallout
policy that you want to modify. - Add the property
keepalive.timeout.millis
with an appropriate value under the<HTTPTargetConnection>
element in theTargetEndpoint
configuration.For example to change the keep alive timeout to
30
seconds, add the following block of code:<Properties> <Property name="keepalive.timeout.millis">30000</Property> </Properties>
Since the
keepalive.timeout.millis
property is in milliseconds, the value for30
seconds is30000
.The following examples show how to configure the keep alive timeout in the
ServiceCallout
policy of your API proxy:Example ServiceCallout policy configuration using URL for backend server
<ServiceCallout name="Service-Callout-1"> <DisplayName>Service Callout-1</DisplayName> <HTTPTargetConnection> <Properties> <Property name="keepalive.timeout.millis">30000</Property> </Properties> <URL>https://mocktarget.apigee.net/json</URL> </HTTPTargetConnection> </ServiceCallout>
Example ServiceCallout policy configuration using target server
<ServiceCallout enabled="true" name="Service-Callout-1"> <DisplayName>Service Callout-1</DisplayName> <Response>calloutResponse</Response> <HTTPTargetConnection> <LoadBalancer> <Server name="target1" /> <Server name="target2" /> </LoadBalancer> <Properties> <Property name="keepalive.timeout.millis">30000</Property> </Properties> <Path>/test</Path> </HTTPTargetConnection> </ServiceCallout>
- Save the changes made to your API proxy.
Configuring keep alive timeout on Message Processors
This section explains how to configure the keep alive timeout on the Message Processors. The
keep alive timeout can be configured through the property
HTTPClient.keepalive.timeout.millis
, which represents the keep alive timeout
value in milliseconds on the Message Processor component. Since this property is commented on
the Message Processor, you need to use the special syntax
conf/http.properties+HTTPClient.keepalive.timeout.millis
as described in the section
Set a token that is currently commented out in
How to configure Edge.
To configure the keep alive timeout on the Message Processors, do the following:
- On the Message Processor machine, open the following file in an editor. If it does not already exist, then create it.
/opt/apigee/customer/application/message-processor.properties
For example, to open the file using
vi
, enter the following:vi /opt/apigee/customer/application/message-processor.properties
- Add a line in the following format to the properties file, substituting a value for
TIME_IN_MILLISECONDS:
conf/http.properties+HTTPClient.keepalive.timeout.millis=TIME_IN_MILLISECONDS
For example, to change the keep alive timeout on the Message Processor to
30
seconds, add the following line:conf/http.properties+HTTPClient.keepalive.timeout.millis=30000
- Save your changes.
- Ensure the properties file is owned by the
apigee
user as shown below:chown apigee:apigee /opt/apigee/customer/application/message-processor.properties
- Restart the Message Processor as shown below:
/opt/apigee/apigee-service/bin/apigee-service edge-message-processor restart
- If you have more than one Message Processor, repeat the above steps on all the Message Processors.
Verifying keep alive timeout on Message Processors
This section explains how to verify that the keep alive timeout has been successfully modified on the Message Processors.
Even though you use the special syntax
conf/http.properties+HTTPClient.keepalive.timeout.millis
to set the keep alive
timeout on the Message processor, you need to verify if the actual property
HTTPClient.keepalive.timeout.millis
has been set with the new value.
- On the Message Processor machine, search for the property
HTTPClient.keepalive.timeout.millis
in the/opt/apigee/edge-message-processor/conf
directory and check to see if it has been set with the new value as shown below:grep -ri "HTTPClient.keepalive.timeout.millis" /opt/apigee/edge-message-processor/conf
-
If the new keep alive timeout value is successfully set on the Message Processor, then the above command shows the new value in the
http.properties
file.The sample result from the above command after you have configured keep alive timeout to
30
seconds is as follows:/opt/apigee/edge-message-processor/conf/http.properties:HTTPClient.keepalive.timeout.millis=30000
In the example output above, notice that the property
HTTPClient.keepalive.timeout.millis
has been set with the new value30000
inhttp.properties
. This indicates that the keep alive timeout is successfully configured to30
seconds on the Message Processor. - If you still see the old value for the property
HTTPClient.keepalive.timeout.millis
, then verify that you have followed all the steps outlined in Configuring keep alive timeout on Message Processors correctly. If you have missed any step, repeat all the steps again correctly. - If you are still not able to modify the keep alive timeout, then contact Google Cloud Apigee Edge Support.