IIS 的最佳 GZIP 压缩设置是什么?
您可以将 HcDynamicCompressionLevel 设置为 0-10 之间的任意值。 我听说 10 不好(CPU 使用率高),但是效果最好的神奇数字是多少?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
动态压缩设置为 5 到 9 实际上会影响 CPU 负载。 静态压缩仅发生一次(直到重新缓存文件),并且您可以将静态压缩设置为高。
这篇深入的文章建议4用于动态压缩,7至9用于静态压缩。 本文提供了您可以阅读并自行决定的信息来支持此建议。
http:// /weblogs.asp.net/owscott/archive/2009/02/22/iis-7-compression-good-bad-how-much.aspx
随着 CPU 负载的增加,小型动态页面可以从更高的动态压缩设置中受益与更大的文件。 当页面大小约为 200 KB 时,您需要考虑较低的动态设置。 另请注意,高动态压缩设置会增加从每个页面请求获取第一个字节的时间。 这些因素支持使用更受限制的设置 4 进行动态压缩。
同样,静态资源可以使用较高的设置,因为只有第一个请求会影响 CPU 负载和客户端等待时间。 然而,如果您提供许多大型静态资源,那么静态压缩将不会产生同样的效果,因为您的缓存将填满并开始踢出资源; 因此,压缩资源不会从缓存的重复服务中受益。
注意:没有设置“10”。
还有两件事需要考虑:
.config
文件中的httpCompression
元素具有禁用的设置CPU 负载过高时进行压缩:当 CPU 负载低于指定值时,
EnableCpuUsage
设置会重新启用压缩。另一个设置禁用小文件的压缩:
在意识到某些压缩文件比原始文件大后,IIS 7.5 将压缩的最小文件大小从 IIS 7.0 中默认的 256 字节提高到默认值 2,700 字节。 我不知道 2,700 字节是否最好,但由于 IP 数据包可以合理地约为 1,400 字节,因此此设置将阻止压缩少于两个数据包的文件。 在任意质疑微软提高此设置的决定之前,我想做真正的测试或阅读专家的建议。
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:The
EnableCpuUsage
setting re-enables compression when CPU load drops below the specified value.Another setting disables compression for small files:
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.
当 CPU 比现在慢两个数量级时,10 很糟糕。 就目前的压缩算法而言,gzip 算法相当快,因此我将其设置为 10,看看会发生什么。
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.
我发现将其设置为 8 可以提供相当好的压缩率,而且不会对服务器造成太大影响。 这将取决于您的服务器负载和规格。
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.
在我看来,这确实取决于你的情况。 如果您正在处理大量大文件并且有一些空闲的 CPU 能力,那么数字越大越好。 但是,由于并发连接数较多、文件较小且 CPU 功能较弱,因此数字越小越好。
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.
在我工作的公司中,启用了 ASPX 动态压缩并动态生成 javascript/css 和页面,下载时间似乎更长。 我们尝试将压缩级别设置为 1 和最大值。 cpu 90%,但在没有压缩的情况下仍然最差。 是我的
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