To scale well in the web 2.0 Ajax world, web applications need to handle requests asynchronously. You just cannot afford to have a thread waiting for a response from a webservice or a database while requests are queuing up. I have recently reviewed quite a few ways to do this. Here are the top ones.
- Servlet 3.0 : This is an ongoing JSR still in early stages. An early implementation is available from Jetty. This works quite well and the blogs from webtide show you how to use it. Basically you have two new api methods in ServletRequest , i.e. suspend() and resume() . You suspend when you have to start processing a request which may block the servlet thread and you resume the servlet thread when you are ready to send the response.
- Asyncweb/Mina : Asyncweb is now a subproject of Mina and has a easy to use API . You handle only the request in the handleRequest method and when you are ready with the response you can commit the response to the request.
- xsocket-http : This is new opensource project which provides fantastic api for lot of asynchronous handling of http including a asynchronous http client and http streaming.
I would say a combination of Jetty 7 and xsocket-http client would be ideal combination. After asyncweb moved to to be a module of Mina, I haven't seen it featured on Mina website . Only by browing mailing lists I could find a way to checkout the source code of asyncweb.
The introduction of asynchronous api in servlet 3.0 is very exiting and hopefully we will see other implementations soon from Glassfish/Grizzly and the rest.
No comments:
Post a Comment