Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Apache HttpAsyncClient hangs under load

Tags:

java

http

Using the Apache HttpAsyncClient Beta3, when I load it up with up to 50 concurrent requests to a variety of servers it seems to start out fine, I get about 3000 urls procssed.

But then I hit a wall where I get these connection reset by peer exceptions in the log. At this point the async client simply hangs.

Connection reset by peer would be fine by its self, if the async client passed that on to my callback as an exception, but my callback code doesn't get called and the whole thing just locks up.

2013-02-04 13:52:14,739 ERROR org.apache.http.nio.protocol.HttpAsyncRequestExecutor (I/O dispatcher 9): http-outgoing-139 [ACTIVE] HTTP protocol exception: Connection r
eset by peer
java.io.IOException: Connection reset by peer
        at sun.nio.ch.FileDispatcher.read0(Native Method)
        at sun.nio.ch.SocketDispatcher.read(SocketDispatcher.java:21)
        at sun.nio.ch.IOUtil.readIntoNativeBuffer(IOUtil.java:202)
        at sun.nio.ch.IOUtil.read(IOUtil.java:175)
        at sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:243)
        at org.apache.http.impl.nio.reactor.SessionInputBufferImpl.fill(SessionInputBufferImpl.java:97)
        at org.apache.http.impl.nio.codecs.AbstractMessageParser.fillBuffer(AbstractMessageParser.java:115)
        at org.apache.http.impl.nio.DefaultNHttpClientConnection.consumeInput(DefaultNHttpClientConnection.java:167)
        at org.apache.http.impl.nio.DefaultHttpClientIODispatch.onInputReady(DefaultHttpClientIODispatch.java:125)
        at org.apache.http.impl.nio.DefaultHttpClientIODispatch.onInputReady(DefaultHttpClientIODispatch.java:50)
        at org.apache.http.impl.nio.reactor.AbstractIODispatch.inputReady(AbstractIODispatch.java:112)
        at org.apache.http.impl.nio.reactor.BaseIOReactor.readable(BaseIOReactor.java:160)
        at org.apache.http.impl.nio.reactor.AbstractIOReactor.processEvent(AbstractIOReactor.java:342)
        at org.apache.http.impl.nio.reactor.AbstractIOReactor.processEvents(AbstractIOReactor.java:320)
        at org.apache.http.impl.nio.reactor.AbstractIOReactor.execute(AbstractIOReactor.java:280)
        at org.apache.http.impl.nio.reactor.BaseIOReactor.execute(BaseIOReactor.java:106)
        at org.apache.http.impl.nio.reactor.AbstractMultiworkerIOReactor$Worker.run(AbstractMultiworkerIOReactor.java:604)
        at java.lang.Thread.run(Thread.java:662)
like image 460
David Parks Avatar asked Feb 05 '13 04:02

David Parks


1 Answers

Well, I solved the problem by switching to Netty, far more stable and predictable.

like image 129
David Parks Avatar answered Nov 15 '22 00:11

David Parks