Be Open Source
Java HttpClient and Load Balancer bad interactions
Working for a very big customer, I found a very nasty interaction between Sun HttpClient (JDK 1.4) and Http Load Balancers.
In a complex network environment, sometimes you can experience low level TCP/IP comunication errors, because sometimes HttpClient get confused and hangs.
The bad behavior of Sun HttpClient is well known: some guys suggested me to use the Axis Web Client. Anyway you can solve the issue adding these three parameters to the JVM launch line
-Dsun.net.client.defaultConnectTimeout=5000
-Dsun.net.client.defaultReadTimeout=5000
-Dhttp.keepAlive=false
The first two parameters set globally the socket timeout to 5 seconds.
The last parameter forces the JVM to avoid reusing http connections when doing http request.
To be honest, http.keepAlive=false is not always effective and could have huge performance impacts, so be very carful adopting it.
But if you stick on the two sun.net.client.default* properties (doing some tests) you can solve the issue.
References
From Java Plug-in Control Panel:
[...]
Networking properties description:sun.net.client.defaultConnectTimeout
sun.net.client.defaultReadTimeout
These properties specify, respectively, the default connect and read timeout values for the protocol handlers used by java.net.URLConnection. The default values set by the protocol handlers is -1, which means there is no timeout set.
sun.net.client.defaultConnectTimeout specifies the timeout (in milliseconds) to establish the connection to the host. For example, for http connections it is the timeout when establishing the connection to the http server. For ftp connections it is the timeout when establishing the connection to ftp servers.
sun.net.client.defaultReadTimeout specifies the timeout (in milliseconds) when reading from an input stream when a connection is established to a resource.
For the official description of these properties, see Networking Properties.
[...]
Related posts:
- A very good hosting provider After my past experience with bad hosting provider, I am happy to say I have find a very good hosting...
- April 0.2 Application Performance Framework April (Application Performance Framework) is a super-light application framework based on Spring, featuring: An Aspect Oriennted Programing Performance Monitor, which...
- Apache Rampart Welcome to Apache Rampart Rampart is the security module of Axis2. It secures SOAP messages according to specifications in the...
| Print article | This entry was posted by Giovanni Giorgi on May 21, 2009 at 16:25, and is filed under English Content, Knowledgebase, Software. Follow any responses to this post through RSS 2.0. You can leave a response or trackback from your own site. |