Facebook Invades DCPHP
This 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.
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.