Some fairly large Internet services are pressing into production Facebook’s open-source PHP runtime engine after being impressed with the performance metrics for the alternative to the ubiquitous open-source PHP package used across the Web.
WordPress hosting site WP Engine has found that the Facebook HipHip Virtual Machine (HHVM) executes PHP commands 5.6 times faster than a standard PHP interpreter.
“PHP, compared to HHVM, is wicked slow,” said Tomas Puig, WP Engine’s director of labs. “So I saw an opportunity for us to use HHVM to drive WordPress.”
Enterprise-focused cloud storage provider Box is also using the technology and has been pleased by the results—average request latency dropped by a factor of three when using HHVM.
“The performance gains we’re seeing with HHVM exceeded all expectations,” wrote Box engineer Joseph Marrama, in a blog post announcing Box’s use of HHVM. “Almost every request that touches Box goes through our PHP codebase, so the speed increase is felt almost everywhere.”
Facebook engineers created HHVM as a way to speed the social networking service, which was written largely in the PHP Web development language. Facebook found that many programmers were versatile with the open-source language, which was created in 1994 and is one of the most widely used languages on the Internet.
For Facebook, however, PHP’s performance left something to be desired. PHP itself translates the programmer code to machine code only when it is called by the user, which slows performance. So company engineers created a virtual machine that, like the Java Virtual Machine, would translate the code into machine-readable bytecode just before running it. If the code needed to be used again, a bytecode-ready version would be available in the cache ready to go.
HHVM now powers much of Facebook, with other Web companies starting to use it as well.
WP Engine is one of the largest providers of WordPress hosted services for enterprises. Built on PHP, the open-source WordPress content management platform is increasingly being used for powering rich Internet applications, such as providing the back end for mobile apps and cloud services.
WP Engine recently built its next-generation platform, called Mercury, for running WordPress on HHVM. The company found that Mercury had a 560 percent faster response time than the traditional PHP setup. The company is currently testing the platform, which is also running the site for Web consultancy firm 10up in full production mode.
Box already has HHVM running in production mode to power its core Web storage application, which is used by over 27 million people.
The company first looked at HHVM a couple of years ago, but found it would require too much work porting its code to HHVM. The development team behind HHVM, however, has since made it a priority to offer full compatibility with PHP, which swayed Box to use the technology.
Box did run into some transition challenges. One was the migration from the Apache Web server, which provided an PHP interpreter. HHVM runs an internal copy of the high- performance Nginx Web server instead. The Box engineering team also found a number of bugs in HHVM and sent fixes to the HHVM development team.
Because it is a just-in-time compiler, HHVM requires the code to be called a few times before the performance improvements kick in, to “warm up” the cache with material ready to be served, which was something else Box engineers had to get used to. Box changed internal operations to allow for a brief warm-up time before a new instance of HHVM goes live.
Puig agreed that moving to HHVM requires some up-front work.
“Supporting it from an infrastructure perspective is much better than loading a bunch of servers on a virtual machine with cPanel,” Puig said, referring to the open-source Web hosting control panel cPanel.