Zend Optimizer

With PHP 5.5 Zend Opcache is the default byte opcode caching. For those who do not know what that is. It will compile php scripts into executable byte code and stores it in memory for reuse. Normally php will be compiled every time it is run, which is very inefficient use of your CPU power.

On my development system the update to 5.5 was done automatically some weeks ago and APC (the other opcode caching solution) was not running anymore. Strangly the update did not install opcache, but if you use the following command (given that you have pecl installed) you can run opcache instead of apc

#pecl install zendopcache-7.0.2

I also found a nice monitoring script to see how opcache is doing. Definitely worth installing also.

https://gist.github.com/ck-on/4959032/?ocp.php

The performance I perceived is similar to APC, but the benefit should be that it is more tightly integrated and assures full php compatibility, that has not been the case with APC was my experience. You will loose the file caching capability of APC, but there are plenty of other solutions for this and ELGG is also caching a lot of files by default.

So yesterday I moved the production version of my site to opcache and the performance is good and I did not find any issues yet. The average server response time improvement is 60% to normal php processing. Page load (to DOM ready) is about 40% better. So if you don't have APC, I recommend installing opcache immediately. There is no real downside, just the work you have to do.

Just wanted to share that with you and liked to know what your experiences are.  

  • my server has just received the update to php 5.4.18 - not sure why 5.5 is not through yet.
    i am using APC already though.
    what is the comparison of performance between apc and zend opcache?

  • I do not know, but I do not expect any significant performance changes between APC or OPC. It seems a little bit more stable and since it is linked now to php it must keep track of changes better. You probably do not have to worry and just wait until the 5.5 release is in and watch if APC is still running (mine stopped) . This article is more for those who do no use any opcode caching yet.

  • Very interesting. Could you detail a bit about your benchmarking methodology? I'd like to try it myself when I have some time on my hand.

    Thanks for sharing!

  • For volume testing, I use apache benchmark.  It gives average reponse time of page load in high volumes. You can determine the number of requests and the concurrency. A typical benchmark could be

     ab -n 100 -c 10 http://www.yoursite.com/

    For detailed page load information I used pingdom tools . http://tools.pingdom.com/fpt/ 

    Google pagespeed https://developers.google.com/speed/pagespeed/insights/ is helpfull sometimes for tips on how to improve your site.

  • i just installed php5.5 and the zend opcode github-gist that was linked here.

    when i run php -v i see zend opcache 7.0.2 is listed..

    yet when i run the gist monitor page i see opcache is disabled.

    i have already gone throug the relevant php.ini file and enabled opcache as best i know how to..

    e.g. i included the lines:

    zend_extension=opcache.so
    [opcache]
    ; Determines if Zend OPCache is enabled
    opcache.enable=1

    ; Determines if Zend OPCache is enabled for the CLI version of PHP
    opcache.enable_cli=1

    and i also used the approach here:

    http://fideloper.com/install-zend-opcache

    anyone know what i am missing?
    thanks

  • That basically should work, check /etc/php.d/opcache.ini and make sure that "opcache.enable=1"  or find out where opcache.so is located and that lib is actually loaded in apache

  • i found the cause of this and now opcache is running ok.. i hadn't installed the opcache package as i thought it was included with php now... and it is not.

  • No allthough it is the default, it is not yet included. You need to run "pecl install zendopcache-7.0.2" manually , as stated above :-)

  • ;)
    i installed instead through the package installer here - php-opcache-5.5.3.1

  • hmm.. oh.. i just noticed there is also a 7.0.2-2 version

Performance and Scalability

Performance and Scalability

If you've got a need for speed, this group is for you.