Skip to main content

Jezzly or Gretty? Running Jetty on top of Grizzly

Posted by jfarcand on November 9, 2006 at 7:28 PM PST

Since a couple of weeks I've been working with the Jetty team to investigate how we can front Jetty with Grizzly. Well, I'm happy to announce the collaboration worked very well and you can now get a preview of Jetty powered by Grizzly.

taurreau.jpgt

Recently I got an email from Greg Wilkins about exploring a way to use Grizzly in Jetty. The challenge was high because we had to learn each other code to see where we can bridge the two products. Jetty 6 already have an NIO based connector that works pretty well, but still we were interested to see if my NIO tricks can make a difference(see part 1,2,3,4,5). With a couple of emails exchange, we were able to define how to integrate. Our goal was to get the Grizzly framework from the Maven repository, and build the Jetty extension on top of it. Interestingly, the number of classes required are quite small(see the code here). If you are looking to extend Grizzly for your own needs, I recommend you take a look at the current code (and also see the excellent blog from Brian McCallister).

Eager to know how to run it? This is quite easy (Jetty is sooooo easy to configure!)

The easiest way to try it is to build Jetty from source. This is very easy to build it. Next, just do:

   % cd jetty
   % java -jar start.jar etc/jetty-grizzly.xml

You should see:

2006-11-09 21:24:36.331::INFO:  Logging to STDERR via org.mortbay.log.StdErrLog
2006-11-09 21:24:36.625::INFO:  jetty-6.1-SNAPSHOT
2006-11-09 21:24:36.871::INFO:  Started GrizzlyConnector @ 0.0.0.0:8888
INFO:
Grizzly configuration for port 8888
         maxThreads: 15
         minThreads: 2
         ByteBuffer size: 8192
         useDirectByteBuffer: false
         useByteBufferView: false
         maxHttpHeaderSize: 8192
         maxKeepAliveRequests: 256
         keepAliveTimeoutInSeconds: 30
         Static File Cache enabled: true
         Stream Algorithm :JettyStreamAlgorithm
         Pipeline : LinkedListPipeline
         Round Robin Selector Algorithm enabled: false
         Round Robin Selector pool size: 0
         recycleTasks: true
         Asynchronous Request Processing enabled: false

That's it. Very easy.

Now this is just the beginning. We still have to explore how we can use Grizzly ARP to support Jetty Continuation,add non blocking SSL support, etc. It might not work at all, but the current results looks promising.

One thing I would really like to do once Grizzly is fully integrated is to support Jetty in GlassFish, like other Application Server.

But wait, since Jetty can be embedded in JBoss, Jonas and Geronimo, it means Grizzly extensions will be available to all those products :-). That also means I can possibly run some benchmarks where Grizzly compete against Grizzly. I can envision the name of the blog: Can a Grizzly run faster than .......a Grizzly?!!!!

technorati:

Related Topics >>