ED php framework :: Tutorial #6
Performance tuning
Caching is supported. It provides 10-30x faster script execution. All you have to do:

1a. Create local cache of the framework:
    cd /websites/mysite.com/system/
    php create_cache.php

1b. To remove the local cache:
    delete /websites/mysite.com/system/classes/cached.inc

2. Install any of the PHP Accelerator extensions. Some of them are:
   XCache, APC, eAccelerator and Zend Platform.

3. Open php.ini file and set
   zlib.output_compression = On
   zlib.output_compression_level = 5

   These settings will reduce 6-7x the size of the system javascript and 
   stylesheets, which the server sends to the browser.



Install "APC"
wget http://pecl.php.net/get/APC-3.1.3p1.tgz
tar xzvf APC-3.1.3p1.tgz
cd APC-3.1.3p1
/usr/local/apache2/php/bin/phpize
./configure --enable-apc --enable-mmap --with-apxs --with-php-config=/usr/local/apache2/php/bin/php-config
make
make install
Now we have /usr/local/apache2/php/lib/php/extensions/no-debug-non-zts-20090626/apc.so
Now append at the end of php.ini

[APC]
apc.enabled=1
extension=apc.so
apc.shm_size = 48
apc.max_file_size = 5M


Install "XCACHE"
wget http://xcache.lighttpd.net/pub/Releases/1.3.0/xcache-1.3.0.tar.gz
tar -zxf xcache-1.3.0.tar.gz
cd xcache-1.3.0
/usr/local/apache2/php/bin/phpize
./configure --enable-xcache --with-php-config=/usr/local/apache2/php/bin/php-config
make
make install
Now we have /usr/local/apache2/php/lib/php/extensions/no-debug-non-zts-20090626/xcache.so
Now append at the end of php.ini

[xcache-common]
extension = xcache.so

[xcache.admin]
xcache.admin.auth = On
xcache.admin.user = "admin"
;how to create md5 pwd: echo -n "admin"| md5sum
xcache.admin.pass = "21232f297a57a5a743894a0e4a801fc3"

[xcache]
xcache.shm_scheme =        "mmap"
xcache.size  =               32M
xcache.count =                 1
xcache.slots =                8K
xcache.ttl   =              3600
xcache.gc_interval =         300
xcache.var_size  =            0M
xcache.var_count =             1
xcache.var_slots =            8K
xcache.var_ttl   =             0
xcache.var_maxttl   =          0
xcache.var_gc_interval =      300
xcache.readonly_protection =  Off
xcache.mmap_path =            "/dev/zero"
xcache.cacher =               On
xcache.stat   =               On


Install "EACCELERATOR"
mkdir /tmp/eaccelerator
chmod 0777 /tmp/eaccelerator
http://ovh.dl.sourceforge.net/project/eaccelerator/eaccelerator/eAccelerator%200.9.6-rc2/eaccelerator-0.9.6-rc2.tar.bz2
tar --use-compress-program bzip2 -xvf eaccelerator-0.9.6-rc2.tar.bz2
cd eaccelerator-0.9.6-rc2
/usr/local/apache2/php/bin/phpize
./configure --enable-eaccelerator=shared --with-php-config=/usr/local/apache2/php/bin/php-config
make
make install
Now we have /usr/local/apache2/php/lib/php/extensions/no-debug-non-zts-20090626/eaccelerator.so
Now append at the end of php.ini

extension="eaccelerator.so"
eaccelerator.shm_size="16"
eaccelerator.cache_dir="/tmp/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"


APC vs XCACHE vs EAccelerator
We have installed all opcode cachers and we got the following results(for a regular not too complex page):
APC:
Framework classes fully loaded:0.0066
Full page render:0.0107

XCACHE:
Framework classes fully loaded:0.0042
Full page render:0.0068

EAccelerator:
Framework classes fully loaded:0.0038
Full page render:0.0064