Facebook Rocks the PHP World with HipHop - Scaling PHP (
Page 2 of 2 )
In essence, Zhao and the team set out to scale PHP to the point that it
suited Facebook's unique needs. Describing those needs and the benefits of the
HipHop solution, Zhao said:
"Scaling Facebook is particularly
challenging because almost every page view is a logged-in user with a
customized 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 correct 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."
Zhao explained that a key idea for what eventually became HipHop originated
at a Facebook Hackathon a few years ago, at which he worked on code to
transform PHP into C++.
Zhao's post spelled out more of the details of working on the HipHop project
and building out the development team. He also said Facebook has developed a
technology known as HPHPi, which is an experimental interpreter designed for
development. "When using HPHPi you don't need to compile your PHP source
code before running it," he said. "It's helped us catch bugs in
HipHop itself and provides engineers a way to use HipHop without changing how
they write PHP."
In summary, Zhao said:
"Overall HipHop allows us to keep
the best aspects of PHP while taking advantage of the performance benefits of
C++. In total, we have written over 300,000 lines of code and more than 5,000
unit tests. All of this will be released this evening on GitHub under the open
source PHP license."
He also said Facebook engineers will be talking up the HipHop technology at
various open-source and developer conferences, such as FOSDEM (Free and Open Source
Developers' European Meeting) and OSCON (O'Reilly Open Source Convention), over
the next few months.