What's the optimal GZIP compression setting fo

2019-05-18 10:20发布

You can set the HcDynamicCompressionLevel anywhere from 0-10. I've heard 10 is bad (high CPU usage), but what's the magic number that works the best?

5条回答
做个烂人
2楼-- · 2019-05-18 10:45

It seems to me that this would really depend on your situation. If you're serving a lot of large files and have some CPU power to spare, then a higher number would be better. However, as you have more concurrent connections, smaller files, and a less powerful CPU, a smaller number is better.

查看更多
smile是对你的礼貌
3楼-- · 2019-05-18 10:48

In the company I am working for, enabled dynamic compression for ASPX and dynamically generated javascript/css and pages seem to be taking longer to download. We tried setting compression level to 1 and max. cpu 90% but still worst that without compression. Is my

查看更多
小情绪 Triste *
4楼-- · 2019-05-18 10:49

Settings of 5 to 9 for dynamic compression DO in fact hammer CPU load. Static compression occurs only once (until a file is re-cached) and you can set static compression high.

This in-depth article recommends 4 for dynamic compression and 7 to 9 for static compression. The article backs up this recommendation with information that you can read and decide for yourself.

http://weblogs.asp.net/owscott/archive/2009/02/22/iis-7-compression-good-bad-how-much.aspx

Small dynamic pages can benefit from higher dynamic compression settings as CPU load goes up with larger files. At around 200 KB in size you will want to consider a lower dynamic setting for pages. Also, note that high dynamic compression settings increase the time to get the first bytes from each page request. These factors support using the more restrained setting of 4 for dynamic compression.

Once again, static resources can use a high setting because only the first request impacts CPU load and client wait time. Yet, if you serve many large static resources then static compression won't pay off as well because your cache will fill up and begin to kick-out resources; thus, the compressed resources won't benefit from repeatedly being served from cache.

NOTE: There is no setting of '10'.

Two more things to consider:

The httpCompression element in your .config files has settings that disable compression when CPU load is too high:

dynamicCompressionDisableCpuUsage="90"
dynamicCompressionEnableCpuUsage="80"

staticCompressionDisableCpuUsage="100"
staticCompressionEnableCpuUsage="80"

The EnableCpuUsage setting re-enables compression when CPU load drops below the specified value.

Another setting disables compression for small files:

minFileSizeForComp="2700"

IIS 7.5 raised the minimum file size for compression from a default of 256 bytes in IIS 7.0 to a default to 2,700 bytes after realizing some compressed files were larger than the original. I don't know if 2,700 bytes is best, but since an IP packet can reasonably be around 1,400 bytes, this setting would prevent compressing files less than two packets. I would want to do real testing or read the advice of an expert before arbitrarily challenging Microsoft's decision to raise this setting.

查看更多
何必那么认真
5楼-- · 2019-05-18 10:51

I've found that setting it to 8 gives a pretty good rate of compression without hammering the server too much. It will depend on your server load and specification.

查看更多
戒情不戒烟
6楼-- · 2019-05-18 11:02

10 was bad when CPUs were two orders of magnitude slower than they are now. The gzip algorithm is pretty fast as far as compression algorithms go these days, so I'd set it to 10 and see what happens.

查看更多
登录 后发表回答