Should I use Jetty's or NGINX's gzip capabilities in a reverse proxy setup?

守給你的承諾、 提交于 2019-12-20 06:15:07

问题


I am running a Jetty-based Web Service behind an NGINX reverse proxy. Both Jetty and NGINX can handle the gzip compression/decompression for responses and requests. The typical payload is JSON, ranging from a few kilobytes up to tens of megabytes. Especially for larger payloads, the compression significantly impacts overall throughput.

What would be the most efficient point to handle the compression part - the JAVA service (Jetty) or the proxy (NGINX) if both sit on the same server?

Since NGINX uses a C-based gzip library, which is a lot more efficient and faster than JAVA's internal gzip, I would assume that NGINX should do the job. On the other hand, transferring bigger volumes of data between Jetty and NGINX has its own overhead. So I am not sure that the obvious choice is correct.


回答1:


The only way to be sure would be to measure. However, I've done the same thing with .NET Core and Nginx and in that case compressing the JSON in Nginx was more efficient. Microsoft says as much.

Use server-based response compression technologies in IIS, Apache, or Nginx. The performance of the middleware probably won't match that of the server modules

I would assume that the same holds for Java/Jetty and Nginx.



来源:https://stackoverflow.com/questions/54905834/should-i-use-jettys-or-nginxs-gzip-capabilities-in-a-reverse-proxy-setup

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!