Magento on HHVM. Daniel Sloof

20
Magento on HHVM Speeding up your webshop with a drop-in PHP replacement.

description

Magento on HHVM. Daniel Sloof

Transcript of Magento on HHVM. Daniel Sloof

Page 1: Magento on HHVM. Daniel Sloof

Magento on HHVM

Speeding up your webshop with a drop-in PHP replacement.

Page 2: Magento on HHVM. Daniel Sloof

Daniel Sloof

https://twitter.com/daniel_sloof

https://github.com/danslo

[email protected]

Page 3: Magento on HHVM. Daniel Sloof

What is HHVM?

● HipHop Virtual Machine● Created by engineers at Facebook● Essentially a reimplementation of PHP● Originally translated PHP to C++, now

translates PHP to bytecode● Just-in-time compiler, turning generated

bytecode into machine code● In some cases 5 to 10 times faster than

regular PHP

Page 4: Magento on HHVM. Daniel Sloof

Bytecode compilation

Modified? Invalidate cache

Compile to Bytecode

Run Bytecode

No

Yes● PHP5 style bytecode execution

● APC-like caching of bytecode

● Performance is quite similar to Zend PHP

Page 5: Magento on HHVM. Daniel Sloof

Just In Time Compiler

Modified?

Have Native?

Hot?

Invalidate Cache

Compile to Bytecode

Run BytecodeCompile to

Native

Run Native

No

No

Yes

Yes

Yes No

Page 6: Magento on HHVM. Daniel Sloof

What was the problem?

● HHVM not entirely compatible with PHP● Magento’s PHP triggering many of these

incompatibilities● Choosing between

○ Forking Magento to work around HHVM○ Fixing issues within the extensive HHVM C++

codebase

Page 7: Magento on HHVM. Daniel Sloof

Resulted in... fixing HHVM

● Already over 100 commits fixing Magento related HHVM bugs;○ SimpleXML (majority of bugfixes)○ sessions○ number_format○ __get and __set○ many more...

● Most of these fixes already merged back into the official (github) repository

● Still actively involved and committed to make HHVM a good place for Magento

Activity for the HHVM project on github in June

“Of the top 15 contributors, only 9 are facebook employees.”

Page 8: Magento on HHVM. Daniel Sloof

What that means for Magento...

● Community and Enterprise Editions running stable.

● Passes near 100% of the Test Automation Framework.

● Large boost in improvement.● Works with FastCGI, so keep most of your

current web-configuration, rewrites, etc.

Page 9: Magento on HHVM. Daniel Sloof

Benchmarks

Before we go to the results...● Magento 1.9 with sample data● Standard nginx / php-fpm / percona stack

(with PHP 5.5 opcode cache)● Standard HHVM configuration (repo-

authoritative mode disabled, JIT enabled)● Tool of choice: siege

Page 10: Magento on HHVM. Daniel Sloof

Benchmarks: Response time

Average across 50 requests

Page 11: Magento on HHVM. Daniel Sloof

Benchmarks: Transaction rate

While increasing siege concurrency until avg. response time ~2 seconds

Page 12: Magento on HHVM. Daniel Sloof

What about <insert caching solution here>?

● HHVM does not get in the way● Dynamic content still needs to be generated● Replaces PHP - not Varnish, Redis, FPC,

Block Cache, etc.● As long as you are burning CPU cycles

(always), you will benefit from HHVM● Think about speeding up indexing, order

placement, routing, etc.

Page 13: Magento on HHVM. Daniel Sloof

What about PHPNG / PHP7?

● Better performance than PHP5.5, but still trails behind HHVM quite significantly.

● Not production ready.

http://goo.gl/MyUBeu

Page 14: Magento on HHVM. Daniel Sloof

How do we know it is stable?

● Unfortunately there are no unit tests for (core) Magento 1.x

● Brushed up the Test Automation Framework● Automated setup of test environment using

Chef● Nightly builds to check Magento compatibility

on HHVM to make it easier to spot regressions

● Open-sourced very soon

Page 15: Magento on HHVM. Daniel Sloof

What about the future?

● Facebook is committed to open source: several employees work on it exclusively.

● HHVM tracks a number of popular frameworks and runs their PHPUnit suites

● Magento 2 is part of that list

http://hhvm.com/frameworks/

Page 16: Magento on HHVM. Daniel Sloof

What is Hack?

Moving to HHVM gets even more awesome.● Statically typed language● Type annotations● Generics● Async● Lambda’s● Collections● Built-in user attributes

Page 17: Magento on HHVM. Daniel Sloof

Can we gradually migrate?

Store not entirely compatible with HHVM and still want to run it.● Problem is isolated to a (subset of) page(s):

use web-server configuration to split load.● Problem is more widespread (incompatible

global observers, ioncube, etc):https://github.com/danslo/HiphopIndexer/

Page 18: Magento on HHVM. Daniel Sloof

On the topic of debugging

● HHVM comes with something called HPHPd● CLI Based, comparable to GDB● No (known) support for any IDEs

Latest stable release has xdebug support!

Page 19: Magento on HHVM. Daniel Sloof

Where can we run it?

Leading platform for merchants and dev shops running high performance Magento apps in the cloud● Highly optimized Magento PaaS● 24/7 white glove DevOps support● Over 1 billion hours deployed on AWS

https://www.engineyard.com/magento

Page 20: Magento on HHVM. Daniel Sloof

Thank you!

Questions?