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.