Site Moves from PHP to Facebook's HipHop, Now Pages Load in .6 Seconds Instead of Five

If you code in PHP have you ever wondered about moving to Facebook's HipHop JIT Virtual Machine for PHP? With HipHop Facebook achieved over a 9x increase in web request throughput and over a 5x reduction in memory consumption compared to Zend PHP 5.2 engine + APC.

But will HipHop really work for you? Is it really drop-in compatible? Is it really as fast as they say?

To answer questions like this nothing beats a good experience report and here's a great one: Adventures in Configuring and Running Facebook's HipHopVM (hhvm) JIT Compiler for PHP by Yermo Lamers.

Yermo selected PHP to implement a number of content web sites. He took an interesting approach, he created a forms, views, validation, and business logic description language to remove the drudgery of creating the same code over and over again for each page. Having done this in Perl I think it's a great a approach. The problem is it can be slow. PHP's slow string handling makes dynamically evaluating a description template for each page very slow. Up to 5 seconds.

Rather than rewrite in C++ Yermo tried HipHop. The results were impressive:

  • Pages which loaded in 5 seconds now load in 0.6 seconds.
  • Very few modifications to the codebase were required, with only two functions out of 500 files needing to be changed. Though tracking down problems was quite involved.
  • Uses half as much memory.
  • When problems were encountered the community in IRC was very helpful in finding and fixing the problems with Facebook employees responding in detail.

Though not quite a proper drop-in experience, the results seem worth the effort. Many others have reported similar or better experiences. So if you are using PHP and are looking for a magic bullet type fix HipHop may be just what you are looking for.

And kudos to Yermo for writing a domain specific language to help with the incredible tedium of typical web processes. Many programmers have probably thought of doing something similar when coding yet another form screen, so just do it. You don't always have to use someone else's framework. You can build your own.