Facebook Invades DCPHP

Posted by on May 4, 2010
 

Facebook's HipHop for PHPThis past week, the DCPHP Developers’ Community had the privilege of hosting Scott MacVicar from Facebook. His title is “Open Source Developer Advocate” which puts him in the odd position of making good things happen within Facebook, representing them to the community, and convincing the community to get involved. Towards that goal, this presentation was the last stop of a short tour to present HipHop to PHP groups.

First off, Scott shared some amazing statistics about Facebook: It hosts more images and receives more images per day than Flickr. The entire system includes nearly four billion lines of code. The average user time on the site is 55 minutes/day. There are no joins at the database level. The system includes “tens of thousands of servers” split between a pair of hosting facilities. These servers handle 800M+ requests/day. And as fast as PHP is in terms of learning, coding, and deployment, its speed doesn’t compare to a compiled language like C, C++, or even Java.

This is where HipHop comes into play. HipHop takes your PHP and translates/transforms into C++, optimizes it like crazy, and compiles it into a binary appropriate for distribution and deployment. Depending on how you benchmark and test performance, you could see upwards of 100% performance improvement.

Of course, there are a few downsides. Since your code is transformed and compiled at deployment, some of the most dynamic aspects like eval() usage or variable-variable-variable messes simply won’t work. Even more of a potential problem, since HipHop packages your code with its own web server and doesn’t actually use the Zend Engine, you may see slightly different behavior in deployment. Scott stated Facebook’s commitment to duplicate the Zend Engine’s behavior exactly but it’s still a work in progress.

Other than the technical questions, the next big question Scott answered was:

Why would Facebook release HipHop?

His answer was two fold. First, he acknowledged how Facebook – and Mark Zuckerberg specifically – got its start based on Open Source technology. Without the LAMP stack, Facebook simply wouldn’t exist. Second was a much more practical reason: Facebook can’t do it all. They need help testing, debugging, and supporting more extensions and architectures. He identified a number of places to help and suggested exploring Facebook’s GitHub account to get started.

If you’re interested in learning more about HipHop, Scott is giving a presentation next week in the TEK·X Webcast Series and the full HipHop presentation at TEK·X in May.

Disclosure: Scott MacVicar and I traveled together on the CodeWorks tour last year, have had a number of drinks together at various conferences, and I extended the invite from the DCPHP Community.


About the author—Keith Casey has been a developer for over a decade and helps organize various tech communities. Previously, he was a professional agitator within the Washington, DC until he decided to explore Austin, TX in 2010. To pay the bills, he works as a Developer Evangelist for Twilio to get good tools to good developers so they can build great things. Previously, he built large-scale PHP-based systems for organizations ranging from major news companies to small non-profits. In his spare time, he is a core contributor to web2project, works to build and support the Austin PHP community, co-founded the HubAustin coworking space in South Austin communities, blogs regularly at CaseySoftware.com and is completely fascinated by monkeys.