Fastest way to get Http response status in Java

I am doing a little research and tests to get the status code from an Http response.

I need to get the response status code from a large list of sites using the fastest way, I can’t work in multiple threads, this will work in a batch process, and this is necessary.

I created a small test service that sends a request several times (avoiding the site cache) and retrieves time statistics.

I test different clients and APIs, but the response time is not good enough (min. 200 ms, average: 300-400 ms).

I am testing with Java URLConnection, SpringRestTemplate, ApacheHttpCommons, GoogleHttpClient and Restlet. One of the problems that I discovered is that in some of them I'cant only asks for HEAD and then retrieves the sode state, so I select the full answer.

I also think about sockets and scripts.

Any help would be appreciated a lot.

+3
source share
1 answer

Lack of streaming is the big problem of having slow response times (probably 99% network latency - a particular HTTP library is hardly significant).

You can try http://mina.apache.org/asyncweb/ , which is built on Java NIO and therefore is non-blocking, but can create threads in the background.

+2
source

All Articles