Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which PHP opcode cacher should I use to improve performance? [closed]

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

  • APC - Installation Guide
  • eAccelerator - Installation Guide
  • XCache - Installation Guide

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

[Update 1]

HowtoForge installation links added

[Update 2]

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

  • Login
  • Access Home Page

With 50 concurrent connections, the results are as follows:

No Opcode Caching
No Opcode Caching

APC
APC

eAccelerator
eAccelerator

XCache
XCache

Performance Graph (smaller is better)
Performance Graph

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.

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

  • Package is available in official Debian repository
  • More functional control panel

To summarize my experience:

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

like image 344
Edmund Tay Avatar asked Aug 26 '08 17:08

Edmund Tay


People also ask

What is PHP OpCode cache?

What are OpCode Caches? OpCode Caches are a performance enhancing extension for PHP. They do this by injecting themselves into the execution life-cycle of PHP and caching the results of the compilation phase for later reuse. It is not uncommon to see a 3x performance increase just by enabling an OpCode cache.

How do I enable PHP OpCode caching?

Enabling opcode caching If you do not see the Select PHP Version icon, your server does not support this feature. Select the check box next to the opcode caching extension you want to enable: If you are using PHP version 5.4 or older, select apc. If you are using PHP version 5.5 or newer, select opcache.

What is cached by an OpCode cache?

OPcache is a type of caching system that saves precompiled script bytecode in a server's memory called a cache, so each time a user visits a web page, it loads faster.


2 Answers

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.

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.

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

like image 106
mercutio Avatar answered Sep 24 '22 12:09

mercutio


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

Benchmark Results 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).

Zend Optimizer made everything slower (!).

like image 20
BlaM Avatar answered Sep 25 '22 12:09

BlaM