[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: TUX and a Java servlet engine



Michael K. Johnson wrote:


The first way to get a performance boost for servlets would be to compile them to native code with gcj, I would think...

Is that JDK1.3 compliant and ready for the enterprise yet? (stability)



The TUX interface is event-driven instead of connection-oriented, which means that existing code written to a connection-oriented API is hard to port. H

<thinking out loud, and having no knowledge of Tux>


Perhaps a simple Tux module could be written to read the entire client message and post that to the servlet-runner via TCP.
The servlet-runner could spawn a worker thread who would prepare the entire response event/message and ask the servlet-runner
to talk to Tux over TCP to have Tux send the response out.

Notes:
1. HttpRequest.inputStream would be essentially pointing to a ByteArrayInputStream created from the event message received
by Tux.

2. HttpResponse.outputStream would essentially be pointing to a ByteArrayOutputStream (baos). When the post is done you call baos.getBytes() and send that to Tux (somehow). Whether this works or not depends on how Tux handles HTTP headers - I'm sure
this is too simple and won't work exactly as written...


3. There needs to be some way for the servlet-runner to tell Tux that "this" data needs to be sent to client (socket) X. I'm sure
the API provides this.

This could provide a non-blocking asynchronous solution to the Java problem of one thread -> one socket. Tux could have a *lot*
of connections waiting for a response while a much smaller number of worker threads are processing the requests in Java.
Java would only need one thread that waited for response objects to appear in an outgoing queue and fire them to Tux.

The caveat here is that the worker threads don't expect to stream data back to the client. If this is the case then you are back
to the one thread->one socket mapping unless you do a lot more non-blocking I/O in the servlet (perhaps using the Java NBIO
library Matt Welsh wrote). That would be a lot of work.

Thoughts?

--
Mark Swanson
Principal Architect
TechSpan
12900 Federal Systems Park Dr.
Suite 2B
Fairfax, Virginia 22033






[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index] []