users@glassfish.java.net

NIO design question

From: cowwoc <cowwoc_at_bbs.darktech.org>
Date: Sun, 10 Aug 2008 09:54:27 -0700 (PDT)

Hi,

I've got an NIO design question and I figured the Glassfish community might
know the answer because of Grizzly. If not, please suggest where I should
ask this question.

I'm looking for advice on how to implement the following architecture in a
scalable way. Can NIO be used for this?

- My application exposes a bunch of servlets. Multiple clients invoke those
servlets simultaneously.
- I want to limit the number of connections across the application (all
servlets) and have a separate limit on the number of connections per
specific servlet.
- When a servlet is invoked, I want to push a Callable onto a worker thread
(which imposes the above limits) and have the servlet thread recycled back
into the web server without closing the underlying connection.
- The worker thread would eventually service the client, but a single worker
thread would service potentially thousands of waiting clients.

Why do I want to these limits? Because some servlets are very expensive (cpu
and memory) and are likely to cause database update collisions.

The problem is that I don't know how to return from the servlet body without
closing the underlying connection. I believe the web container closes it
automatically.

Any ideas?

Thanks,
Gili
-- 
View this message in context: http://www.nabble.com/NIO-design-question-tp18914899p18914899.html
Sent from the java.net - glassfish users mailing list archive at Nabble.com.