Tag Archives: hiphop

HipHop for PHP

A break away from styling my site theming my site to blog about quite an exciting development announced yesterday by Facebook, a new opensource project called HipHop for PHP. My preferred language of choice for the past 8 or 9 years has been PHP, I started my commercial education with Perl but quickly migrated to PHP mainly because of its close ties with MySQL at the time. For the language zealots out there PHP is an oft derided language but you can’t deny its popularity and many of the reasons Facebook have cited in their use of PHP hold true for my tech team at Five by Five. But one complaint – PHP doesn’t scale – simply won’t go away, I guess this is largely because PHP is pretty CPU/memory intensive to run. Well HipHop for PHP will supposedly go some way to help this.

Facebook serves up an astonishingly large number of pageviews (4 Billion per month has been cited), and they use PHP. I’d say they’ve managed to scale it, of course its not really that simple, there’s lots of components to the Facebook stack but to do what they’ve done serves as a pretty good benchmark for PHP. Now it looks like they’ve gone one step further, they’ve taken the advantages of using PHP and without sacrificing them have improved the efficiency of serving up the site to improve the scalability.

In a nutshell, or as far as I can gather, HipHop for PHP takes the native code written as per usual in plain PHP and transforms it into C++ which is then compiled to be run. I won’t go into the technical details in this post but suffice to say for Facebook this Voodoo magic works and its now in their production environment on 90% of there servers, gaining them upto around 50% less CPU usage, in theory it means they won’t have to scale their hardware for a while.

What does it mean to the average coder. Well in my opinion not a lot, the vast majority of sites built don’t have the scalability issues that Facebook have. The paltry number of hits my blog receives for instance wouldn’t benefit from using HipHop and to be honest adding a compile step into my deployment process would probably slow me down, its a bit too much like Java for my liking. It does however give a viable option if I do need to scale my site without having to move to a multiple server architecture which is expensive. Of course there are still a myriad of other options to consider first, agressive caching, code optimisations etc but HipHop for PHP adds another option and another argument against the PHP doesn’t scale mob.

I guess it means that if you can code PHP you can code C++… or then again maybe not.