Nginx – Should I compress resources with a loadbalancer (Nginx) or with a web server (IIS7)

compressiongzipiis-7load balancingnginx

I have the following setup:

  • Nginx (1.1.19) on the front as a reverse proxy / loadbalancer
  • IIS7 at the back as web servers
  • MySQL as a database

I am trying to figure out whether to compress static resources like JS, CSS etc. and generated HTML with the loadbalancer or with the web servers? Can Nginx pass the already compressed responses it receives from IIS to the client normally or is is better to do the compression on Nginx? If the compression in done with IIS, the traffic between it and and the Nginx would be smaller.

I should of course measure which option is better, but before that, has anyone experience with similar setups? What worked for you and why did you end up in that solution?

Thanks!

Best Answer

You should keep this on the webserver, as a Load Balancer is usually (should be) optimized to do just that, not for modifying content.

Of course you can do it on the LB, but you most likely would need to beef it up a lot - resources which are of more use at the webserver. IMO.