我应该使用哪个PHP操作码cacher来提高性能?

时间:2022-09-10 23:05:59

I'm trying to improve performance under high load and would like to implement opcode caching. Which of the following should I use?

我试图在高负载下提高性能,并希望实现操作码缓存。我应该使用以下哪一种?

I'm also open to any other alternatives that have slipped under my radar.

我也愿意接受任何其他在我的视野之外的选择。

Currently running on a stock Debian Etch with Apache 2 and PHP 5.2

目前运行在一个有Apache 2和PHP 5.2的Debian Etch上

[Update 1]

(更新1)

HowtoForge installation links added

HowtoForge安装链接添加

[Update 2]

(更新2)

Based on the answers and feedback given, I have tested all 3 implementations using the following Apache JMeter test plan on my application:

根据给出的答案和反馈,我已经在我的应用程序上使用以下Apache JMeter测试计划测试了所有3种实现:

  • Login
  • 登录
  • Access Home Page
  • 访问主页

With 50 concurrent connections, the results are as follows:

对于50个并发连接,结果如下:

No Opcode Caching
我应该使用哪个PHP操作码cacher来提高性能?

没有操作码缓存

APC
我应该使用哪个PHP操作码cacher来提高性能?

APC

eAccelerator
我应该使用哪个PHP操作码cacher来提高性能?

eAccelerator

XCache
我应该使用哪个PHP操作码cacher来提高性能?

XCache

Performance Graph (smaller is better)
我应该使用哪个PHP操作码cacher来提高性能?

性能图(越小越好)

From the above results, eAccelerator has a slight edge in performance compared to APC and XCache. However, what matters most from the above data is that any sort of opcode caching gives a tremendous boost in performance.

从上面的结果来看,与APC和XCache相比,eAccelerator在性能上略有优势。然而,从上面的数据中最重要的是,任何类型的操作码缓存都能极大地提高性能。

I have decided to use APC due to the following 2 reasons:

由于以下两个原因,我决定使用APC:

  • Package is available in official Debian repository
  • 包可以在官方的Debian存储库中获得
  • More functional control panel
  • 更多的功能控制面板

To summarize my experience:

总结一下我的经验:

Ease of Installation: APC > eAccelerator > XCache
Performance: eAccelerator > APC, XCache
Control Panel: APC > XCache > eAccelerator

安装方便:APC > eAccelerator > XCache性能:eAccelerator > APC, XCache控制面板:APC > XCache > eAccelerator。

7 个解决方案

#1


16  

I think the answer might depend on the type of web applications you are running. I had to make this decision myself two years ago and couldn't decide between Zend Optimizer and eAccelerator.

我认为答案可能取决于您正在运行的web应用程序的类型。两年前我必须自己做这个决定,不能在Zend Optimizer和eAccelerator之间做出决定。

In order to make my decision, I used ab (apache bench) to test the server, and tested the three combinations (zend, eaccelerator, both running) and proved that eAccelerator on its own gave the greatest performance.

为了做出决定,我使用了ab (apache bench)来测试服务器,并测试了三种组合(zend、eaccelerator,都在运行),并证明了eaccelerator本身的性能最好。

If you have the luxury of time, I would recommend doing similar tests yourself, and making the decision based on your results.

如果您有充裕的时间,我建议您自己做类似的测试,并根据结果做出决定。

#2


5  

I use APC because it was easy to install in windows and I'm developing on WAMP.

我使用APC是因为它很容易安装在windows上,我正在WAMP上开发。

Integrating APC into PHP6 was discussed here: http://www.php.net/~derick/meeting-notes.html#add-an-opcode-cache-to-the-distribution-apc

在这里,我们讨论了将APC集成到PHP6中:http://www.php.net/~derick/会议-notes.html#add- opcode-cache-to- distributionapc。

And there are directions on installing APC on Debian Etch here: http://www.howtoforge.com/apc-php5-apache2-debian-etch

关于在Debian Etch上安装APC的说明如下:http://www.howtoforge.com/apc-php5-apache2-debian-etch

#3


5  

I have run several benchmarks with eAcclerator, APC, XCache, and Zend Optimizer (even though Zend is an optimizer, not a cache).

我使用eAcclerator、APC、XCache和Zend Optimizer运行了几个基准测试(虽然Zend是一个优化器,而不是缓存)。

Benchmark Results http://blogs.interdose.com/dominik/wp-content/uploads/2008/04/opcode_wordpress.png

基准测试结果http://blogs.interdose.com/dominik/wp-content/uploads/2008/04/opcode_wordpress.png

Result: eAccelerator is fastest (in all tests), followed by XCache and APC. (The one in the diagram is the number of seconds to call a WordPress home page 10,000 times).

结果:eAccelerator是最快的(在所有测试中),然后是XCache和APC。(图中是调用WordPress主页10,000次的秒数)。

Zend Optimizer made everything slower (!).

Zend优化器使一切都变慢(!)。

#4


4  

I can't tell you for sure, but the place where I am working now is looking at APC and eAccelerator. However, this might influence you - APC will be integrated into a future release of PHP (thanks to Ed Haber for the link).

我不能肯定地告诉你,但是我现在工作的地方是APC和eAccelerator。但是,这可能会影响您——APC将集成到PHP的未来版本中(感谢Ed Haber提供的链接)。

#5


3  

I've had good success with eAccelerator (speed improvement with no load is noticable) but XCache also seems pretty promising. You may want to run some trials with each though, your application might scale differently on each.

我在eAccelerator上取得了很好的成功(没有加载速度的提高),但是XCache似乎也很有希望。不过,您可能想要对每个应用程序运行一些测试,您的应用程序可能在每个测试上都有不同的扩展。

#6


1  

I've been using XCache for more than a year now with no problems at all.

我已经使用XCache一年多了,没有任何问题。

I tried to switch to eAccelerator, but ended up with a bunch of segmentation faults (it's less forgiving of errors). The major benefit to eAccelerator is that it's not just an opcode cache, it's also an optimizer.

我试图切换到eAccelerator,但最终却出现了一堆分割错误(它对错误的容错不那么宽容)。eAccelerator的主要好处是,它不仅是一个操作码缓存,还是一个优化器。

You should fully test out your application with each one of them to make sure there aren't any problems, and then I'd use apachebench to test it under load.

您应该对每个应用程序进行充分的测试,以确保没有任何问题,然后我将使用apachebench在负载下测试它。

#7


1  

These add-ons have historically introduced lots of weird bugs to track down. These bugs can cause inconsistent behaviour which can't be diagnosed easily because it depends on the state of the cache.

这些附加组件历史上已经引入了许多奇怪的bug来追踪。这些错误可能会导致不一致的行为,不能很容易地诊断出来,因为这取决于缓存的状态。

So I'd say:

所以我说:

  1. Don't use any of the above. Buy more tin instead, it's a more reliable (i.e. error-free) way of increasing performance. OR
  2. 不要使用以上任何一种。买更多的罐头代替,这是一个更可靠的(即没有错误的)提高性能的方法。或
  3. Go with whichever of the above is the most robust, having tested the pants off your application.
  4. 在测试过应用程序后,选择上述最健壮的方法。

But I'd say:

但我想说:

  1. Make sure it's REALLY PHP code parsing that is causing your performance problems by profiling your application. I think it's extremely likely that it isn't - in which case you'd be wasting your time (actually, using your time negatively productively) by installing any of them.
  2. 通过分析应用程序,确保真正导致性能问题的是PHP代码解析。我认为这很有可能不是——在这种情况下,你安装其中任何一个都是在浪费你的时间(实际上,是消极地利用你的时间)。

#1


16  

I think the answer might depend on the type of web applications you are running. I had to make this decision myself two years ago and couldn't decide between Zend Optimizer and eAccelerator.

我认为答案可能取决于您正在运行的web应用程序的类型。两年前我必须自己做这个决定,不能在Zend Optimizer和eAccelerator之间做出决定。

In order to make my decision, I used ab (apache bench) to test the server, and tested the three combinations (zend, eaccelerator, both running) and proved that eAccelerator on its own gave the greatest performance.

为了做出决定,我使用了ab (apache bench)来测试服务器,并测试了三种组合(zend、eaccelerator,都在运行),并证明了eaccelerator本身的性能最好。

If you have the luxury of time, I would recommend doing similar tests yourself, and making the decision based on your results.

如果您有充裕的时间,我建议您自己做类似的测试,并根据结果做出决定。

#2


5  

I use APC because it was easy to install in windows and I'm developing on WAMP.

我使用APC是因为它很容易安装在windows上,我正在WAMP上开发。

Integrating APC into PHP6 was discussed here: http://www.php.net/~derick/meeting-notes.html#add-an-opcode-cache-to-the-distribution-apc

在这里,我们讨论了将APC集成到PHP6中:http://www.php.net/~derick/会议-notes.html#add- opcode-cache-to- distributionapc。

And there are directions on installing APC on Debian Etch here: http://www.howtoforge.com/apc-php5-apache2-debian-etch

关于在Debian Etch上安装APC的说明如下:http://www.howtoforge.com/apc-php5-apache2-debian-etch

#3


5  

I have run several benchmarks with eAcclerator, APC, XCache, and Zend Optimizer (even though Zend is an optimizer, not a cache).

我使用eAcclerator、APC、XCache和Zend Optimizer运行了几个基准测试(虽然Zend是一个优化器,而不是缓存)。

Benchmark Results http://blogs.interdose.com/dominik/wp-content/uploads/2008/04/opcode_wordpress.png

基准测试结果http://blogs.interdose.com/dominik/wp-content/uploads/2008/04/opcode_wordpress.png

Result: eAccelerator is fastest (in all tests), followed by XCache and APC. (The one in the diagram is the number of seconds to call a WordPress home page 10,000 times).

结果:eAccelerator是最快的(在所有测试中),然后是XCache和APC。(图中是调用WordPress主页10,000次的秒数)。

Zend Optimizer made everything slower (!).

Zend优化器使一切都变慢(!)。

#4


4  

I can't tell you for sure, but the place where I am working now is looking at APC and eAccelerator. However, this might influence you - APC will be integrated into a future release of PHP (thanks to Ed Haber for the link).

我不能肯定地告诉你,但是我现在工作的地方是APC和eAccelerator。但是,这可能会影响您——APC将集成到PHP的未来版本中(感谢Ed Haber提供的链接)。

#5


3  

I've had good success with eAccelerator (speed improvement with no load is noticable) but XCache also seems pretty promising. You may want to run some trials with each though, your application might scale differently on each.

我在eAccelerator上取得了很好的成功(没有加载速度的提高),但是XCache似乎也很有希望。不过,您可能想要对每个应用程序运行一些测试,您的应用程序可能在每个测试上都有不同的扩展。

#6


1  

I've been using XCache for more than a year now with no problems at all.

我已经使用XCache一年多了,没有任何问题。

I tried to switch to eAccelerator, but ended up with a bunch of segmentation faults (it's less forgiving of errors). The major benefit to eAccelerator is that it's not just an opcode cache, it's also an optimizer.

我试图切换到eAccelerator,但最终却出现了一堆分割错误(它对错误的容错不那么宽容)。eAccelerator的主要好处是,它不仅是一个操作码缓存,还是一个优化器。

You should fully test out your application with each one of them to make sure there aren't any problems, and then I'd use apachebench to test it under load.

您应该对每个应用程序进行充分的测试,以确保没有任何问题,然后我将使用apachebench在负载下测试它。

#7


1  

These add-ons have historically introduced lots of weird bugs to track down. These bugs can cause inconsistent behaviour which can't be diagnosed easily because it depends on the state of the cache.

这些附加组件历史上已经引入了许多奇怪的bug来追踪。这些错误可能会导致不一致的行为,不能很容易地诊断出来,因为这取决于缓存的状态。

So I'd say:

所以我说:

  1. Don't use any of the above. Buy more tin instead, it's a more reliable (i.e. error-free) way of increasing performance. OR
  2. 不要使用以上任何一种。买更多的罐头代替,这是一个更可靠的(即没有错误的)提高性能的方法。或
  3. Go with whichever of the above is the most robust, having tested the pants off your application.
  4. 在测试过应用程序后,选择上述最健壮的方法。

But I'd say:

但我想说:

  1. Make sure it's REALLY PHP code parsing that is causing your performance problems by profiling your application. I think it's extremely likely that it isn't - in which case you'd be wasting your time (actually, using your time negatively productively) by installing any of them.
  2. 通过分析应用程序,确保真正导致性能问题的是PHP代码解析。我认为这很有可能不是——在这种情况下,你安装其中任何一个都是在浪费你的时间(实际上,是消极地利用你的时间)。