Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Netty vs Nginx: Pros and Cons based on Performance, Memory Management, Memory Footprint

Question: What are the Pros and Cons of Nginx and Netty for using building a Proxy Server.

Elaborating the problem:

We are trying to implement a proxy server (forward or reverse proxy) which is placed in front of a service and takes care of good practices that can be applied on our services.

So we are evaluating different solutions that are available in the market mainly Nginx and Netty. So when we initially did our research on Nginx, we came across a good amount of positive blogs which suggested that Nginx is very fast, easily configurable by writing the custom modules to plugin to Nginx.

But when we did a POC on Netty, we got much better performance numbers while using Netty 4. So I would like to know if some one have performed some comparison between Nginx and Netty and also what are the reasons for not using Netty as a reverse/forward proxy solution. We are worried on GC problems associated with Java Server solutions hence we want to know the Pros and Cons of Nginx and Netty before going ahead with a solution.

Thanks, Vinay.

like image 491
user2604844 Avatar asked Mar 24 '16 14:03

user2604844


1 Answers

I'm not aware of detailed comparisons because you're not comparing apples to apples here. Netty is a very low level java framework, while nginx is a mostly complete proxy. I am not sure what you wrote for your example on netty. Without doing any tests my self I imagine it would be pretty hard to make a functional proxy on netty which is faster than nginx.

I think if you want a simple proxy server you should go with nginx since it will most likely have all the functionality you need for a basic proxy. nginx is fast and mature so it should do very well for the basic use case.

If you are looking at a more complex proxy, with special plugins. Maybe things like ratelimiting/custom authentication, etc. then it might be worth considering using netty. These things can be build on nginx but requires using Lua scripts. You may prefer to use java as a developer.

If you do end up going with netty, just remember you may have to reimplement may complex features such as backend load balancing.

I use a load balancer written on netty, so I don't want to discourage you. I just want to point out that one is a prewritten optimized reverse proxy while the other is one you'd have to write yourself from scratch.

like image 198
Josh Wilson Avatar answered Oct 09 '22 15:10

Josh Wilson