Facebook is about to release some Open Source code that may change the way we write PHP. The project is called HipHop PHP or HHPHP and is a converter and compiler of PHP Code into a static & C++ Runtime.
The project is said to be live on the Facebook site for about 8 months now but its development started over 2 years ago.
In a press release type meeting Facebook gave us some of the framework and also reasoning behind the project.
It seems that the Facebook site like many larger PHP sites was having problems scaling. After looking into optimizing Apache and making use of products like Zend they found little improvement.
They were then faced with the decision to either move their code to another language and lose the speed and resources of their PHP Developer Crew or find a way to convert the PHP Code into C++ and compile portions while using a runtime.
The way it works is when PHP can be converted a database of all the vars and functions is directly translated. Some code can not be easily converted so it did mean a change in some of their base code and will mean a change in future development for their staff.
They also rewrote their HTTP Server to provide better reliability for small calls.
For most sites this will not be a solution because it requires a great deal of planing and understanding of what can and can not be done however if you run a site with over 500k unique visitors a day you may have the resources to deploy a project like this if your code base does not change that often.
Testing requires that you run an original php deployed server against the C++ compiled version and check for function calls when pages are loaded.
The Improvements Found?
It seems they were able to cut about 40% of their memory and 30% of their processor time which is very impressive. It is that extra room that will allow a site to stay online during unforeseen heavy load.
When will it be released?
To quote Facebook it is scheduled for release “sometime in the future” … well thats nice.
Final Note
HipHop may be a solution for some larger projects but for now the idea of compiling code … code that may be very dirty on most websites … well it probably won’t be something we see for 99% of the self hosted sites out there.
And another thing Don’t put up an announcement of your new project against the premier of Lost… thats just dam stupid AND must have made everyone in that room a little mad … that is unless they had widescreens setup in the next room for a lost party.. you can hope that..