Tomcat AIO, NIO and SEDA

2004/11/7

Tomcat AIO, NIO and SEDA

Interesting comment on async IO in Java:

Tomcat + IBM's Asynchronous IO for Java
Posted by: Lukasz Kubica on September 02, 2004

It's not so simple. J have been working on it. I have a prototype (very, very alpha version) which uses SEDA, original Tomcat 5.25 request pipeline and aio or netty-2 for io (it's distributed as a connector). And gues what - i'ts about 20% slower than original (aio is significantly faster than netty). The problem lies in the need of buffering data and there's no simple solution. You have to keep data in the buffer untill it's actually sent (in aio) or till it gets to the writting worker thread (netty).

What's more, it uses much more memory because you have to keep a huge pool of direct buffers. The funny thing is that on windows nio allocates a direct buffer even when you use the byte[] methods. So you end up with out of memory very quickly, because java deallocates direct buffers very, very slowly.