本文介绍了我应该在反向代理设置中使用Jetty或NGINX的gzip功能吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在NGINX反向代理后面运行基于Jetty的Web服务. Jetty和NGINX都可以处理gzip压缩/解压缩以响应和请求.典型的有效负载是JSON,范围从几千字节到数十兆字节.特别是对于较大的有效负载,压缩会显着影响总体吞吐量.

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.

处理压缩部分的最有效点是JAVA服务(Jetty)还是代理(NGINX)(如果两者都位于同一服务器上)?

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?

由于NGINX使用基于C的gzip库,该库比JAVA的内部gzip效率更高,速度更快,因此我认为NGINX应该可以完成这项工作.另一方面,在Jetty和NGINX之间传输大量数据有其自身的开销.因此,我不确定明显的选择是否正确.

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.

推荐答案

唯一可以确定的方法就是测量.但是,我对.NET Core和Nginx做过同样的事情,在这种情况下,在Nginx中压缩JSON更有效. Microsoft 就这么说.

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.

我认为Java/Jetty和Nginx同样适用.

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

这篇关于我应该在反向代理设置中使用Jetty或NGINX的gzip功能吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-23 02:35