Solving Magento

Solutions for Magento E-Commerce Platform

by Oleg Ishenko

Improving Magento Performance with APC Opcode Caching

What is Opcode and why cache it?

As you know, PHP is an interpreted language, and every instruction in your code has to be compiled into intermediate language before being passed over to the web server for execution. This intermediate language is known as Opcode. To see a dump of Opcode generated for your script you can use VLD extension developed by Derick Rethans and available at A sample opcode output for a “Hello World” script would be like this:

<?php echo “Hello”.” “.”World!”; ?>


function name:    (null)
number of ofs:    5
compiled vars: none
line    #  *  op            fetch    ext    return    operands
   2    0  >    EXT_STMT    
    1    CONCAT                    ~0    'Hello', '+'
    2    CONCAT                    ~1    ~0m 'World%21'
    3    ECHO                        ~1
   3    4    >    RETURN                        1

branch: # 0;    line:    2-    3;    sop:    0;  eop:    4

Similarly every line in your code is compiled down every time your server works on a request. Depending on complexity of your application (and Magento, as we know, is quite complex) this process can take rather long, especially when under heavy load. So why not storing processed opcodes in some sort of a cache and return them when necessary instead of going through the entire routine? This what PHP life cycle looks like with and without opcode caching [1]:

Continue reading

Theme: Esquire by Matthew Buchanan.