Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jetty-users] How to use async processing with 3.1 async IO correctly?

I've setup a Github rep for this. Please run following commands - 

git clone git@xxxxxxxxxx:gauravphoenix/jetty91asyncIO.git
cd jetty91asyncIO/jettyTest/
mvn package
java  -Dlog4j.configurationFile=./src/main/resources/log4j.xml  -jar target/jettyTest-1.0-SNAPSHOT.jar

Now, change your browser proxy to localhost:80. 

As you can see, the in the code, it acts as a simple HTTP proxy. If you visit any website (not HTTPS, only HTTP site), you can see first few requests go just fine through proxy but after that nothing really happens. If you try to download a single large file (I've tested with 500+ MB file) it works just fine. So my hunch is that it is the number of requests which matter and not size of data written back to the client. 

Also, as you can see I'm NOT using async processing- just simple async IO. Note that if I don't use ASYNC IO and only async processing, everything works just fine. 

Just a little code walk through- (yea, that's what I call my main class :) setups up Jetty proxy. is the servlet responsible for processing GET requests. Currently only GET is implemented - you can discard this for now - copy paste from  blog 

Let me know if you need any more information. 


On Sat, Nov 23, 2013 at 2:41 PM, Simone Bordet <sbordet@xxxxxxxxxxx> wrote:

On Fri, Nov 22, 2013 at 11:24 AM, Gaurav Kumar <gauravphoenix@xxxxxxxxx> wrote:
> I've been using servlet 3.0 async processing using Jetty 9.0.6.v20130930
> quite nicely- able to handle 7k+ concurrent connections on commodity
> hardware. Now that Jetty 9.1 is GA, I'm trying to use async IO on top of
> async processing.
> Essentially, in my worker thread which processes async context, instead of
> directly writing to output stream, I've set WriteListener which in turn
> writes to output stream. The problem is that after processing few requests,
> Jetty is not accepting new connections- it kind of hangs. Existing client
> connections eventually time out.
> Is there a sample code available somewhere which shows how to use async
> processing with async IO?
> If we take this code as an example-,
> I'm modifying line #42 -
> asyncContext.getResponse().getWriter().printf("ticker: %s, price: %.2f",
> ticker, price);
> and replacing it with
> ServletOutputStream out = response.getOutputStream();
> out.setWriteListener(new StandardDataStream(content,async,out));
> (as mentioned in this
> example-
> but as I mentioned, after processing few requests, Jetty becomes
> unresponsive.
> Any pointers on how to resolve this issue?

You have a fully reproducible test that we can look at (full code) ?

Simone Bordet
Developer advice, training, services and support
from the Jetty & CometD experts.
Intalio, the modern way to build business applications.
jetty-users mailing list

Back to the top