PHP Gets Boost with Facebook’s HipHop
PHP is one of the web’s most widely used and successful programming languages. It’s easy to learn, easy to use, and extremely powerful. Tools like Drupal and Wordpress power millions of sites on Internet, and both were built using PHP.
But mighty Facebook stands above nearly everyone as the king of PHP. With over 400 billion pageviews per month (yes, that’s billion with a ‘b’), Facebook serves up more webpages with PHP than just about anyone else. Facebook’s engineers credit PHP with some of their success because PHP’s simplicity makes it easy to recruit new engineers, quickly train them, and get them started with the site’s code.
But PHP’s ease and simplicity comes with a very real downside for Facebook. Like most scripted languages, PHP is substantially slower than compiled languages like C and C++. Smaller sites running on fast servers may never notice PHP’s performance inadequacies, but Facebook faced the real possibility of spending millions of dollars for additional servers just to support PHP’s overhead.
Just how complex is Facebook’s PHP implementation? To quote Facebook engineer Haiping Zhao:
Scaling Facebook is particularly challenging because almost every page view is a logged-in user with a customized experience. When you view your home page we need to look up all of your friends, query their most relevant updates (from a custom service we’ve built called Multifeed), filter the results based on your privacy settings, then fill out the stories with comments, photos, likes, and all the rich data that people love about Facebook. All of this in just under a second.
To solve this problem, Facebook has created a new tool called HipHop which they’re releasing today as an open source project for anyone to use. HipHop actually converts PHP to C++ which can then be compiled with g++. By running 90% of their PHP scripts through HipHop, Facebook reduced their server utilization by an astounding 50%!
What does HipHop mean for you? Well, if you’re a developer it gives you a new option for improving your site’s performance, although other tools like Zend Server may be a better choice until HipHop has a chance to mature.
If you’re a tester, HipHop represents yet another layer of tools that could potentially fail. More interestingly, it opens the possibility of finding bugs common to compiled languages (buffer overflows, NULL pointer references, off by one errors, etc.) in what appears to be an interpreted language.
Are you a PHP developer or tester? What do you think of HipHop?






This is really a great tool that Facebook has built and kudos to them for releasing it to the world under an free/open source license. It’s worth noting that the vast majority of those deploying PHP applications will either a) not be able to use HipHop and/or b) not get any benefit out of using HipHop. There are many reasons for this and others have written some excellent blog posts on the topic, but I’ll mention a few of the reasons here:
1. HipHop won’t work on shared hosting environments which is where many PHP applications are deployed.
2. The bottleneck in most PHP applications is not PHP itself. Database access, for example, is usually a much bigger bottleneck. At Facebook’s scale it makes sense to take performance improvements wherever you can get them.
3. If you have only one web server then you don’t gain very much by using HipHop. You can’t buy half a web server so cutting your resource usage in half doesn’t get you much.
Bradley,
All three of those are excellent points. Thanks!