30.06.2016 Views

Magento Site Performance Optimization

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Caching Them All<br />

HipHop Virtual Machine<br />

HipHop Virtual Machine (HHVM) is the cornerstone of the PHP processing stack of<br />

Facebook and is currently able to increase the number of requests handle by a server<br />

by 9. It is open source and you can download it on GitHub. How does it work? As<br />

we can write a whole book (or two) about HHVM, we will just give the key ideas<br />

here. HHVM is a virtual machine that will translate any called PHP file into a HHVM<br />

byte code in the same spirit as the Java or .NET virtual machine. HHVM transforms<br />

your PHP code into a lower level language that is much faster to execute. Of course,<br />

the transformation time (compiling) does cost a lot of resources, therefore, HHVM is<br />

shipped with a cache mechanism similar to APC. This way, the compiled PHP files<br />

are stored and reused when the original file is requested. With HHVM, you keep<br />

the PHP flexibility and ease in writing, but you now have a performance like that of<br />

C++. Hear the words of the HHVM team at Facebook:<br />

"HHVM (aka the HipHop Virtual Machine) is a new open-source virtual<br />

machine designed for executing programs written in PHP. HHVM uses a justin-time<br />

compilation approach to achieve superior performance while maintaining<br />

the flexibility that PHP developers are accustomed to. To date, HHVM (and its<br />

predecessor HPHPc) has realized over a 9x increase in web request throughput and<br />

over a 5x reduction in memory consumption for Facebook compared with the Zend<br />

PHP 5.2 engine + APC.<br />

HHVM can be run as a standalone webserver (in other words, without the Apache<br />

webserver and the "modphp" extension). HHVM can also be used together with a<br />

FastCGI-based webserver, and work is in progress to make HHVM work smoothly<br />

with Apache."<br />

If you think this is too good to be true, you're right! Indeed, HHVM have a major<br />

drawback. HHVM was and still is focused on the needs of Facebook. Therefore, you<br />

might have a bad time trying to use your custom made PHP applications inside it.<br />

Nevertheless, this opportunity to speed up large PHP applications has been seen<br />

by talented developers who improve it, day after day, in order to support more and<br />

more framework. As our interest is in <strong>Magento</strong>, I will introduce you Daniel Sloof<br />

who is a developer from Netherland. More interestingly, Daniel has done (and still<br />

does) an amazing work at adapting HHVM for <strong>Magento</strong>.<br />

Here are the commands to install Daniel Sloof's version of HHVM for <strong>Magento</strong>:<br />

1. $ sudo apt-get install git<br />

2. $ git clone https://github.com/danslo/hhvm.git<br />

3. $ sudo chmod +x configure_ubuntu_12.04.sh<br />

4. $ sudo ./configure_ubuntu_12.04.sh<br />

5. $ sudo CMAKE_PREFIX_PATH=`pwd`/.. make<br />

[ 70 ]<br />

www.it-ebooks.info

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!