We have a healthcheck page in a web application, which is accessed by various tools to check whether the application is running normally. This page has to load fast, within 100ms.
Now, in the servlet code, we hit another application's healthcheck page like this:
HttpURLConnection myConn = (HttpURLConnection) myUrl.openConnection();
if (myConn .getResponseCode() != HttpServletResponse.SC_OK)
{
...
}
Now, getResponseCode() seems to be taking a long time (~500 to 1000ms).
On profiling with NetBeans, we found out that internally java.net.SocketInputStream.read(byte[], int, int) is taking all the time.
Any idea on how to optimize?
All comments, suggestions, etc are welcome!