Keep-Alive property in WSO2 ESB

Posted: June 17, 2014 in Uncategorized
Tags: , , , ,

Imagine a scenario where ESB is configured to forward request to a backend service. Client sends request to the ESB, ESB forward the request to the backend service. Backend service send response to the ESB and then ESB forward the response to the client.

When ESB forward the request to the backend service, ESB create a TCP connection with the backend server.  Below is wireshark TCP stream filter for a single TCP stream.

TCP packets exchanging for a single request response

TCP packets exchanging for a single request response

You can see there are multiple TCP packets exchanging. They are
SYNK
SYNC ACK
ACK
#other ACK s
FIN ACK
FIN ACK
ACK

You will see there are 6 additional TCP packets other than for the data for a single TCP connection. When client sends multiple requests to the same proxy, ESB has to repeat the same task over and over again. Everytime 6 more TCP packets are wasted. Keep-Alive is the way to avoid it. When Keep-Alive is on, ESB does not create TCP connection for every request-response connection, rather it use the same connection to pass data with the backend. The idea is to use a single persistent connection for multiple requests/responses.

Below image clearly show difference  how ESB communicates with the backend when Keep-Alive is turned off and on.

keepalive

Difference when Keep-Alive is turned on and off

Disable Keep-Alive

By default Keep-Alive is TRUE in ESB. However there might be scenarios where backend service does not support keep-alive. In that case we have to switch off the keep-live as below

<property name="NO_KEEPALIVE" value="true" scope="axis2"/>

Above will not disable Keep-Alive for every meditations. If you want to disable Keep-Alive globally you have to add the property to the repository/conf/passthru-http.properties property file as below

http.connection.disable.keepalive=true

References

http://en.wikipedia.org/wiki/HTTP_persistent_connection
http://tldp.org/HOWTO/TCP-Keepalive-HOWTO/overview.html

Advertisements
Comments
  1. Anuruddha says:

    Nice explanation!! Thanks for sharing this.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s