As predicted, Facebook has delivered a new PHP platform called HipHop for PHP that delivers much improved performance to the popular PHP scripting language that is known for its relative lack of performance.
As Facebook uses PHP extensively for many of its systems, the social networking leader put a small team of engineers together to come up with a solution to the PHP performance issues, as well as scalability issues-because scalability of dynamic, or scripting, languages has been an area of concern for some of the huge social networking platform providers. Twitter has had a number of difficulties in scaling Ruby. And Facebook set out to whip PHP into a scalable, well-performing, well-behaved citizen of its IT environment.
SD Times initially got wind of the PHP doings at Facebook.
Haiping Zhao, the Facebook engineer that launched the project, said, "Scripting languages are known to be far less efficient when it comes to CPU and memory usage. Because of this, it's been challenging to scale Facebook to over 400 billion PHP-based pages views every month." Yet, PHP is so popular because of its simplicity, he said. It is "Simple to learn, simple to write, simple to read, and simple to debug," he said. "We are able to get new engineers ramped up at Facebook a lot faster with PHP than with other languages, which allows us to innovate faster."
During the last two years the team toiled away in stealth mode, finally unleashing HipHop on Feb. 2. And despite the scale challenges, HipHop is showing a payoff. In a blog post about the new technology, Zhao wrote:
""Today I'm excited to share the project a small team of amazing people and I have been working on for the past two years: HipHop for PHP. With HipHop we've reduced the CPU usage on our Web servers on average by about fifty percent, depending on the page. Less CPU means fewer servers, which means less overhead. This project has had a tremendous impact on Facebook. We feel the Web at large can benefit from HipHop, so we are releasing it as open source this evening in hope that it brings a new focus toward scaling large complex websites with PHP. While HipHop has shown us incredible results, it's certainly not complete and you should be comfortable with beta software before trying it out.""
""HipHop for PHP isn't technically a compiler itself. Rather it is a source code transformer. HipHop programmatically transforms your PHP source code into highly optimized C++ and then uses g++ to compile it. HipHop executes the source code in a semantically equivalent manner and sacrifices some rarely used features-such as eval()-in exchange for improved performance. HipHop includes a code transformer, a reimplementation of PHP's runtime system, and a rewrite of many common PHP Extensions to take advantage of these performance optimizations.""