Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Netty based non-blocking REST framework

Tags:

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.

like image 235
Vaibhav Raj Avatar asked Nov 03 '13 21:11

Vaibhav Raj


People also ask

How is Netty non-blocking?

Netty's asynchronous, non-blocking I/O model is designed for highly scalable architectures and may allow for higher throughput than an analogous blocking model. Basically, a non-blocking server runs all requests asynchronously on a single thread (no function should “block” the event loop).

Why Netty is used?

The main purpose of Netty is building high-performance protocol servers based on NIO (or possibly NIO. 2) with separation and loose coupling of the network and business logic components. It might implement a widely known protocol, such as HTTP, or your own specific protocol.

Who is using Netty?

1.2. 1. Who uses Netty? Netty has a vibrant and growing user community that includes large companies such as Apple, Twitter, Facebook, Google, Square, and Instagram, as well as popular open source projects such as Infinispan, HornetQ, Vert.

Why is Netty so fast?

Netty is very fast, especially with many connections. In my experience: It's more scalable than the standard Java IO. In particular, the old synchronous Java IO packages require you to tie up one thread per connection.


1 Answers

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.

like image 178
Adam Gent Avatar answered Oct 27 '22 00:10

Adam Gent