Facebook re-write takes PHP to an enterprise past
Remember C++? They do
Facebook's re-written PHP to transform the dynamic language for fast performance on web-scale server farms without adding additional hardware.
The site's engineers have announced HipHop, which turns the popular and dynamic PHP code into highly optimized but static C++ and then compiles it using the GNU C++ compiler, g++. The change has been released to the community under the PHP license, and you can read more here.
It's quite a change for a social network site that's a posterchild for the Web 2.0 revolution and online services, built on the new generation of scripting languages such as PHP and Agile development methodology of hacking code for short project cycles.
C++ is traditionally associated with the reliable - but relatively unexciting - world of enterprise and server-side computing.
And, while Facebook announced HipHop on Tuesday, the truth is it's already completely committed to the architecture: HipHop's been running on Facebook's thousands of servers for the last six months, with 90 per cent of the site's traffic now running through the transformed PHP.
The company claimed it's cut the CPU use on its servers by up to 50 per cent, depending on the page thanks to HipHop's transformation of PHP.
David Recordon, Facebook's senior open programs manager, told The Reg this translates into cost savings as the company can manage its existing server farms while also adding additional traffic to its service. "We can scale the site in active users and face views and can get more from current hardware without buying more servers," Recordon said.
HipHop started as a skunkworks project two years ago as Facebook realized in 2007 it needed to make some fundamental change to its server architecture if it was to keep growing while avoiding the cost - and systems management pain - of simply adding more servers to its already large server farm. Among the options under discussion were re-writing the site in a completely different language, optimize the Zend PHP engine it uses from Zend Technologies, or work on PHP caching in the applications server
Facebook ruled out a language re-write as it would never be able to keep up while engineers did submit changes to the Zend engine, but the changes didn't go far enough Recordon said.
The plan for HipHop now is to support PHP 5.3 in the next few months - it's currently on version 5.2. Aside from that, Recordon said Facebook wants community feedback.
He noted HipHop would not create a fork in the PHP community, as HipHop would only be of interest to a narrow section of users - those, like Facebook, running very large sites. He said Facebook wanted to "minimize" the differences between PHP and HipHop.
"HipHop makes sense at our scale, but not for everyone," Recordon said. "Most people will continue using PHP today." ®
Sponsored: Global DDoS threat landscape report