NIO vs OIO
Bruno de Carvalho
kindernade at gmail.com
Wed Jul 28 10:30:38 EDT 2010
Just went over the slides and I was a bit skeptical...
So I decided to run a couple of simple tests against the simplest of
HTTP servers* built using Netty and I'm reading 8.5~9k req/second using
a NioServerSocketChannelFactory (on the server bootstrap) versus
~650req/second OioServerSocketChannelFactory.
The http client opens up 25 connections and fires up 1000 non-pipelined
HTTP 1.1 requests (reuses the same 25 connections) with no interval
(burst). This batch is ran 100 times to avoid warmup statistical
anomalies and I'm consistently getting that Nio is faster than Oio, even
for a single connection!
What's more odd is that with Oio, HTTP 1.0 (closing after each response
is sent) requests are faster than HTTP 1.1! Seems that the more I write
on a socket, the slower it gets.
So for HTTP 1.0, both Nio and Oio are balanced (which makes sense since
most of the time is spent opening connections/waiting for connections to
open) but for HTTP 1.1 (keep-alive connections), Nio severely
outperforms Oio (Oio actually gets slower than in HTTP 1.0).
Another interesting note is that for HTTP 1.1, Nio-based server causes
the CPU to hit 80% while the Oio-based server seems to be slacking off
(5%) most of the time.
// The only thing I changed in the server which
// was running only on Nio before:
ChannelFactory f;
if (this.useOldIo) {
f = new OioServerSocketChannelFactory(
Executors.newCachedThreadPool(),
Executors.newCachedThreadPool()));
} else {
f = new NioServerSocketChannelFactory(
Executors.newCachedThreadPool(),
Executors.newCachedThreadPool()));
}
this.bootstrap = new ServerBootstrap(f);
The messageReceived() method on the server handler calls calls write()
at the end.
Any hints on why Oio is so slow in these keep-alive connections?
Bruno
* The server accepts pretty any method and then replies with an xml
<breakfast_menu> example: http://www.w3schools.com/XML/xml_examples.asp
On Wed, 2010-07-28 at 15:54 +0530, Marc-André Laverdière wrote:
> That wasn't my question actually.
> My question was more: are there any tweaks in Netty's OIO
> implementation to take advantage of this?
>
> Marc-André LAVERDIÈRE
> "Perseverance must finish its work so that you may be mature and
> complete, not lacking anything." -James 1:4
> mlaverd.theunixplace.com/blog
>
> /"\
> \ / ASCII Ribbon Campaign
> X against HTML e-mail
> / \
>
>
>
> 2010/7/28 "이희승 (Trustin Lee)" <trustin at gmail.com>:
> > Even a simple discard client-server testing shows NIO outperforms OIO
> > when the number of concurrent connection is greater than 10 in my brand
> > new Core2Quad i7 laptop. If the number of connections are small, it's a
> > known fact that OIO has better throughput, but it never scales up under
> > serious pressure.
> >
> > Of course, OIO works just fine if your business logic takes long enough
> > because raw I/O performance doesn't matter much since it's not a bottleneck.
> >
> > Anyway, Netty has both OIO and NIO transport, so you can switch to OIO
> > if you really need to do so. :)
> >
> > HTH,
> > Trustin
> >
> > On 07/28/2010 05:18 PM, Marc-André Laverdière wrote:
> >> I just had a look at this article:
> >> http://www.thebuzzmedia.com/java-io-faster-than-nio-old-is-new-again/
> >>
> >> It turns out that OS improvements and multicore processors make it
> >> faster to use OIO instead of NIO.
> >>
> >> How can Netty users take advantage of those benefits?
> >>
> >> Marc-André LAVERDIÈRE
> >> "Perseverance must finish its work so that you may be mature and
> >> complete, not lacking anything." -James 1:4
> >> mlaverd.theunixplace.com/blog
> >>
> >> /"\
> >> \ / ASCII Ribbon Campaign
> >> X against HTML e-mail
> >> / \
> >>
> >> _______________________________________________
> >> netty-users mailing list
> >> netty-users at lists.jboss.org
> >> https://lists.jboss.org/mailman/listinfo/netty-users
> >
> > --
> > what we call human nature in actuality is human habit
> > http://gleamynode.net/
> >
> >
> > _______________________________________________
> > netty-users mailing list
> > netty-users at lists.jboss.org
> > https://lists.jboss.org/mailman/listinfo/netty-users
> >
>
> _______________________________________________
> netty-users mailing list
> netty-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/netty-users
More information about the netty-users
mailing list