It’s all in a day’s work

If only a day had 48 hours…
  • rss
  • Home
  • About DelGurth

PHP Acceleration with eAccelerator

DelGurth | Thursday, May 8, 2008

With high traffic sites, performance issue’s rise. Now one of the solutions is to use an opcode caching mechanism for PHP. There are two mainstream open source solutions for that, APC and eAccelerator. And there is Zend platform and Zend core.

Installing eAccelerator
I found a very straight forward howto about installing eAccelerator (and others) on Debian.

But, as always, there are some problems with that tutorial. First the -- is replaced by a special character on that tutorial (and in my blog if I don’t use the <code> tag) in the configure command, so that doesn’t work if you copy paste it. The working configure command is:


./configure --enable-eaccelerator=shared --with-php-config=/usr/bin/php-config

And you don’t need to do all the work as root, only the apt-get, the make install and the php.ini editing should be done as root (best practice, only use root privileges when needed).

Also the double quotes are changed into a special character in that tutorial, so if you get an error in your logs about unable to load \xe2\x80\x9deaccelerator.so\xe2\x80\x9d you copied them just like I did ;-)

This is what I put in the php.ini, without the special double quotes, and with one change


extension="eaccelerator.so"
eaccelerator.shm_size="16"
eaccelerator.cache_dir="/var/cache/eaccelerator"
eaccelerator.enable="1"
eaccelerator.optimizer="1"
eaccelerator.check_mtime="1"
eaccelerator.debug="0"
eaccelerator.filter=""
eaccelerator.shm_max="0"
eaccelerator.shm_ttl="0"
eaccelerator.shm_prune_period="0"
eaccelerator.shm_only="0"
eaccelerator.compress="1"
eaccelerator.compress_level="9"

The tutorial writer creates the cache directory in /tmp. But he fails to make the remark that /tmp is cleared on server restart. So that’s not really a good option. So I’ve done the following in stead


sudo mkdir /var/cache/eaccelerator
sudo chown www-data /var/cache/eaccelerator
sudo chmod 0755 /var/cache/eaccelerator

Yes, the 0644 from the eAccelerator wiki is what you want for the files being created in there, but not for the directory itself.

The big disadvantage of this way of installing it, is that you probably need to recompile it (after a make clean) and reinstall it on every update of PHP. But reading up on APC vs eAccelerator made me choose for the latter.

But does it really help?
Now, the results. What better to test then my own PHP blog (and yes it’s not the fastest one, it’s running on a VPS).

Before installing eAccelerator:

Server Software:        Apache/2.2.8
Server Hostname:        blog.delgurth.com
Server Port:            80

Document Path:          /
Document Length:        44436 bytes

Concurrency Level:      10
Time taken for tests:   397.121299 seconds
Complete requests:      1000
Failed requests:        0
Write errors:           0
Total transferred:      44796000 bytes
HTML transferred:       44436000 bytes
Requests per second:    2.52 [#/sec] (mean)
Time per request:       3971.213 [ms] (mean)
Time per request:       397.121 [ms] (mean, across all concurrent requests)
Transfer rate:          110.16 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.3      0       6
Processing:   712 3961 1674.7   3696   10696
Waiting:      368 2177 1013.3   2033    6943
Total:        712 3961 1674.7   3696   10696

Percentage of the requests served within a certain time (ms)
  50%   3696
  66%   4454
  75%   4977
  80%   5270
  90%   6225
  95%   7039
  98%   8188
  99%   8632
 100%  10696 (longest request)

After installing eAccelerator

Server Software:        Apache/2.2.8
Server Hostname:        blog.delgurth.com
Server Port:            80

Document Path:          /
Document Length:        44436 bytes

Concurrency Level:      10
Time taken for tests:   242.584585 seconds
Complete requests:      1000
Failed requests:        0
Write errors:           0
Total transferred:      44796000 bytes
HTML transferred:       44436000 bytes
Requests per second:    4.12 [#/sec] (mean)
Time per request:       2425.846 [ms] (mean)
Time per request:       242.585 [ms] (mean, across all concurrent requests)
Transfer rate:          180.33 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.2      0       4
Processing:   430 2419 983.2   2330    6409
Waiting:      100  648 448.6    578    3025
Total:        430 2419 983.2   2330    6409

Percentage of the requests served within a certain time (ms)
  50%   2330
  66%   2798
  75%   3051
  80%   3246
  90%   3712
  95%   4182
  98%   4614
  99%   4901
 100%   6409 (longest request)

So it helps also quite a bit on my wordpress install, it’s about a 33% performance increase!

Some material I read

  • Some benchmarks of opcode caches (in german)
  • Some performance tips with some more reading material
  • A benchmark on APC vs eAccelerator on Drupal
  • A benchmark on APC vs eAccelerator vs XCache on Drupal
  • Another benchmark and an explanation about the differences between APC and eAccelerator

P.s. yet another wordpress rant, if you have empty lines between <code> tags, wordpress inserts <p> tags there for you. Not very nice to my liking, since it breaks the formatting of the <code> tag, which I used to format the apache bench results…

Comments
No Comments »
Categories
Debian, Optimizing performance, PHP, Testing
Tags
eaccelerator, optimizing, performance, PHP
Comments rss Comments rss
Trackback Trackback


Categories

  • Debian (4)
  • Debian/Ubuntu (6)
  • Dell D830 (2)
  • Development (1)
  • E65 (1)
  • Eclipse (4)
  • Etch (2)
  • Feisty (2)
  • General (3)
  • Hardy (3)
  • Internet Explorer (1)
  • Java (1)
  • JSP (1)
  • JSTL (1)
  • Misc (3)
  • Nokia (1)
  • one-liners (1)
  • Optimizing performance (1)
  • Packages (2)
  • Phones (1)
  • PHP (2)
  • Postfix (1)
  • SQL Injection (1)
  • SVN (3)
  • Testing (3)
  • Ubuntu (6)
  • Ubuntu x86_64 (2)
  • VOIP (1)
  • Wordpress (7)

Friend blogs

  • AgileMore
  • Borselaer.org
  • Schapendonk.org
  • Twistedmind’s site

Sites I like

  • Joel on Software
  • The Tom Kyte Blog
  • Windows Keyboard Shortcut of the Day

Archives

  • December 2008 (1)
  • November 2008 (1)
  • October 2008 (4)
  • September 2008 (1)
  • August 2008 (6)
  • May 2008 (4)
  • April 2008 (1)
  • March 2008 (1)
  • February 2008 (2)
  • December 2007 (1)
  • November 2007 (3)
  • October 2007 (2)
  • September 2007 (3)
  • August 2007 (1)
rss Comments rss valid xhtml 1.1 design by jide powered by Wordpress get firefox