Netty based non-blocking REST framework

Vaibhav Raj picture Vaibhav Raj · Nov 3, 2013 · Viewed 34.4k times · Source

I am working on a RESTfull application which requires high scalability. I am considering Netty based frameworks for RESTfull applications. I went through some of the available options and tried to get what they can offer as a non-blocking implementation. Here are my findings:

  1. rest.li --> Still under experimental phase for Netty based NIO implementaions. So, not production ready.
  2. RESTEasy --> Standard JBoss project which supports Netty 4.x. But,instead of full stack Netty based NIO implementation, RESTEasy is a Buffer exchange between Netty and RESTEasy. It's not taking the advantages of Netty. Therefore scalability is not as high as expected from a Netty based framework.
  3. Netty-http component --> Another option is Apache Camel integration while using Netty-http component as an endpoint for routing requests to services exposed in from of beans. I think it's same as RESTEasy, only Netty-http component uses Netty based NIO capabilities and the rest of the system would use the old IO. I don't think I would help much in gaining scalabiltiy.
  4. RESTExpress --> It claims to be Netty based framework for RESTFull application. But, neither it has a decent community nor it can be trusted (Because it's very new) for enterprise application which requires high degree of security.

Before having the above findings, I wanted to use some ready to use framework and get the work done faster.

I know it's an opinion based question. But, still I seriously need help for choosing right framework for my application. If in case, there is no Netty based REST framework: would it be wise to go for plumbing low level Netty based NIO code in my application? Any help appreciated. Thanks in advance.

Answer

Adam Gent picture Adam Gent · Nov 5, 2013

If you really want non-blocking you need to do non-blocking from the ground up and have proper REST clients. Otherwise as stated in my comment the performance difference will be negligible and in many cases worse for NIO (Netty with thread sharing).

There only two libraries that I know do non-blocking from the ground up Vert.x and somewhat Finagle (its missing other things like non-blocking data access).

You should also know Tomcat and various other servlet containers that can work with JAX-RS support NIO. The issue is that even though NIO is supported it will still be a single thread per request. Only Play, Finagle, Vert.x and pure Netty (regardless of NIO) support a different shared threading model and thus have different mechanisms for doing concurrency.