Facebook’s PHP Runtime HipHop, now Open Source

In the need for speed, Facebook had been working under the hood to boost PHP runtime to crazy levels which were not possible before. Facebook has now Open sourced the underlying code, as predicted.

The PHP runtime has in fact been rewritten, but it comes with an extra effort: The PHP is translated to C++ (which is of course more efficient) which is then compiled with g++. The project is called HipHop and has been in development under great secrecy at Facebook for the past 2+ years.

With HipHop, Facebook claims to have reduced the CPU usage on average by about 50%. HipHop for PHP isn’t technically a compiler itself, rather a source code transformer. HipHop automatically transforms  PHP source code into highly optimized C++ and then uses g++ to compile it.

Apart from this, They have discussed the challenges faced while scaling a PHP application. Scripting languages like PHP, perl, etc are known to be far less efficient when it comes to CPU and memory usage than interpreted, compiled languages like C++, Java. All this creates it even harder to scale an application written in PHP.

Scaling Facebook is particularly challenging because almost every page view is a logged-in user with acustomized experience. When you view your home page we need to look up all of your friends, query their most relevant updates (from a custom service we’ve built called Multifeed), filter the results based on your privacy settings, then fill out the stories with comments, photos, likes, and all the rich data that people love about Facebook. All of this in just under a second. HipHop allows us to write the logic that does the final page assembly in PHP and iterate it quickly while relying on custom back-end services in C++, Erlang, Java, or Python to service the News Feed, search, Chat, and other core parts of the site.

Finding new ways to improve PHP performance isn’t a new concept. At run time the Zend Engine turns your PHP source into opcodes which are then run through the Zend Virtual Machine. Open source projects such as APC and eAccelerator cache this output and are used by the majority of PHP powered websites. There’s also Zend Server, a commercial product which makes PHP faster via opcode optimization and caching. Even compiling PHP isn’t a new idea, open source projects like Roadsend and phc compile PHP to C, Quercuscompiles PHP to Java, and Phalanger compiles PHP to .Net.

There’s in-depth discussion about how it works, at the source.

PHP is currently used by popular and large, dynamic web sites such as FacebookWordPress.com and Digg.  It was viewed as one of the hottest new technologies in 2005, when venture capitalist Marc Andreessen, founder of Netscape and current Facebook board member, told the Wall Street Journal that “PHP is to 2005 what Java was to 1995.”

What is notable now is – This new effort from Facebook could mold into acceleration for the industry adoption of PHP. The biggest bottleneck is now gone for good.

We write about Open Source, Programming, Web, Apple, iPhone, Android and latest in Tech @taranfx on Twitter.

GD Star Rating
loading...
GD Star Rating
loading...

8 thoughts on “Facebook’s PHP Runtime HipHop, now Open Source”

  1. HipHop seems really interesting, we have had to switch to lighttpd and xcache to achieve huge performance benefits for our objectCMS framework which is now faster that wordpress, joomla and drupal. I am wondering how hiphop compares to lighttpd and xCache, does anyone know when hiphop is going to be released to the public.

    GD Star Rating
    loading...
    GD Star Rating
    loading...
    Reply
  2. They have opensourced the code? really? because I don't see the source code anywhere. Someone's taking blog post headlines out of their butt.

    PS your comment form does not degrade without javascript, and it did not load correctly the first time.

    GD Star Rating
    loading...
    GD Star Rating
    loading...
    Reply
  3. Hello every body!
    I would like to tell all if who are expert in php programming please in code example with small project how to upload and show image from database(mysql…).
    Thank you in advance.

    GD Star Rating
    loading...
    GD Star Rating
    loading...
    Reply
  4. It was nice to see the thoughts and phrases of your and it was commendable to read.
    I can say that you have mentioned a useful stuffs of information in the given article.
    Thanks for sharing this nice piece of information with us.
    Hope for some more updates from you.

    GD Star Rating
    loading...
    GD Star Rating
    loading...
    Reply

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.