directory-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Trustin Lee <>
Subject Re: [mina] Writing to an IoSession
Date Tue, 25 Oct 2005 10:59:46 GMT
Hi Dave,

2005/10/25, Irving, Dave <>:
> Im writing an Http server based on Mina. The tutorial was great and got
> me started in the right direction. I'm using a "stateful" parser
> approach like that used in ASN1 - and it fitted in very nicely.
> Currently, I can ** parse ** around 24,000 HTTP requests per second -
> and with multiple (non-HTTP-pipelining) connections, I can service
> around 700 requests a second. This will improve massively in a few days
> when I implement keep-alive.
> So - after that background, I first want to say a big thank-you for
> MINA. So far, it has proved very stable, and very fast - and hey, I was
> getting bored of writing selector loops anyway :o)

This sounds great. It would be very great if you can provide us some
benchmark results against Tomcat and Apache HTTPD / Apache HTTPD 2 if you
can. Are you able to do that for us? Of course we can run benchmark by
ourselves if we can access your HTTP server implementation.

One question I do have: Currently Im holding on to the IoSession
> associated with a request so that when a response becomes available
> (asyncronously), it knows where to write it to. I cant see any other way
> of knowing where a response is destined for.
> E.g, (cut down, sort of psudo-code)
> /**
> * Invoked asyncronously when a response is comitted - and ready to be
> * written
> */
> void handleResponse(Request req, Response resp, Object marker) {
> IoSession session = req.getContext().getSession();
> ByteBuffer buff = getBufferFor(resp);
> session.write(buff, marker);
> }

Yes there's no other way to find out what session is associated with request
right now. But you could maintain an IdentityHashMap<Request, IoSession>
based on sessionOpened() and sessionCreated() event:

void handleResponse(Request req, Response resp, Object marker) {
IoSession session = req2sessionMap.get( req );
byteBuffer buf = getBufferFor( resp );
session.write( buf, marker );

BTW which version of MINA are you using? It seems like you're using only I/O
layer. Am I right?

what we call human nature is actually human habit

View raw message