3

我在我的服务器上启用了 zlib 和 Zend Optimizer,我已经阅读了关于

zlib.output_compression

指示。在我的服务器中打开此指令是否有任何警告?

4

4 回答 4

8

首先,您应该确定瓶颈是什么(或可能处于负载之下)。
通过打开(透明)压缩,您可以用 CPU 资源换取数据(网络)吞吐量。因此,您必须考虑:我的数据(高度)可压缩吗?将数据传输到客户端所需的时间是瓶颈吗?我可以为压缩花费多少 CPU 资源?我的脚本还使用了哪些其他资源(例如内存消耗、数据库连接……)?哪个资源会成为(重)负载下的瓶颈?脚本的一个实例何时、何地以及多长时间会阻塞另一个实例?依此类推。

您可能还对YSlow之类的工具、xdebug 中内置的分析器apache 基准测试工具、(代码)缓存(如apc ......等等)感兴趣。

于 2010-06-02T18:15:09.310 回答
3

The single most effective thing you can do to speed up PHP code is run an opcode cache.

Zend Optimizer+ is one example. The older Zend Optimizer (without the "+") was a code optimizer, not an opcode cache, and it could actually slow down PHP code if you didn't use an opcode cache.

After you do that, then comes a lot of hard work to test for bottlenecks (as other people have mentioned). You'll need to refactor your code carefully to mitigate the bottlenecks. Most performance experts say that performance problems are caused by poor application architecture more than individual lines of code.

Caching content that you'll need to show multiple times is also a common solution for improving performance. But deciding what content to cache, and for how long, is another area where you need to do testing and experimentation and exercise judgment.

Consider that the bottleneck might not be in your PHP code at all. It could be that your database doesn't have the right indexes. Finding the right indexes given the queries you need to run is also meticulous work and involves testing.

Also frequently your bottleneck can be in the client. Even if your PHP code runs quickly on the server, the page could load inefficiently in the browser, creating a perception of poor performance.

IMHO, all web designers and developers should make Steve Souders books and blogs required reading.

This also relates to the zlib configuration you were asking about, and client performance measurement tools like YSlow and Google PageSpeed.

于 2010-06-02T19:30:23.100 回答
2

学习剖析。
然后优化瓶颈。

于 2010-06-02T18:03:50.997 回答
1

输出压缩是要走的路。将压缩级别设置为 1,因为它提供了最大的节省/CPU 开销比率。默认级别是 1-9 的 6 级,这可能会因为一些额外的字节而减慢速度而效率低下。

于 2010-06-29T01:08:20.810 回答