3

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!

  • A new question came to mind: If the IIS serves already compressed content to Nginx doesn't this mean that Nginx uses less memory for buffering (http://wiki.nginx.org/HttpProxyModule#proxy_buffers)? At least according to book "Mastering Nginx" pages 101-104 it could be deduced so. E.g. if I have 8x128kB = 1024kB proxy buffers and the response from the proxy is 1536kB then the buffer becomes full and 512kB worth gets written to disk. But if I can compress the response under 1024kB, then none is written to disk and the smaller it is, the less memory it consumes. – Pirkka Rannikko Jul 10 '13 at 11:17
  • We decided to do the compression with IIS. noCompressionForHttp10 and noCompressionForProxies settings were relevant in order to make the compression work with Nginx. See http://serverfault.com/questions/23788/need-help-with-some-iis7-web-config-compression-settings and http://www.iis.net/configreference/system.webserver/httpcompression – Pirkka Rannikko Jul 26 '13 at 07:23

2 Answers2

2

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.

Roman
  • 3,825
  • 3
  • 20
  • 33
0

There's often no benefit in using compression inside LAN due to increased latency and enough bandwidth margin anyway, but when it casts traffic out — to Internet, it makes sense. Also, backend usually is being saved from extra-work and this is the second reason to use nginx for compression instead of IIS.

poige
  • 9,171
  • 2
  • 24
  • 50