Filip Hanik - Dev Lists wrote:
gents, so I finally think I have a stable NIO implementation that is doing fairly well.

I have an idea for a next generation of the NIO connector that I wanted to present so that you can comment and if you'd like help out with.

NIO GEN 2

Current Implementation
----------------------
* Non blocking until the entire request has been received
* Blocking for servlet read
* Blocking for servlet write

Suggested implementation
------------------------
* Non blocking until the entire request has been received(same as above)
* Blocking for servlet read (same as above)
* Non blocking for servlet write (new feature)

Explanation
-----------
This feature is very much like the SENDFILE feature for static content, but will
work with dynamic content and keep alive connections.
Of course this could work as a java sendfile for static content as well.

Goal
----
Thread reduction, as each worker thread only spends the time it takes to generate the data.
Thread count no longer is tied to concurrent requests being handled/written
Slow clients will no longer tie up server threads

Features
--------
Ability to have a pluggable "data pool" ie, to avoid running over the java heap with data to be written, this component can be pluggable with one that writes to disk, and can be made fairly intelligent.


Negatives
---------
Much more memory consumption, and I mean much much more if the data pool is pure in memory

I guess it's the trick I documented in the Asynchronous writes section of chapter 25: if there's a "large" amount of content that won't change too often, then you write it to a dumb file, and then use sendfile.

However, using memory to buffer (which could well be the only practical implementation if it's to be magically done by the container) is indeed expensive, and given threads are simple and not that expensive, I didn't see it as very practical (and problem: what if the servlet does a flush ?). In a way, it's as if the buffer size for the servlet was infinite, right ?

It's a nice experiment, though, and could give interesting results.

Rémy

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to