PHP too slow for Facebook, builds its own faster version

The SD Times suggests that a new in-house runtime was built -- the bit of software that executes the PHP code -- but the commenters suggest otherwise: they just think it's a 'pre-compiler' type tool. Basically, PHP is compiled at execute time -- when you visit a page on Facebook, the code they've written is compiled there and then. In contrast, most software that you run on your computer will be pre-compiled. The time it takes to compile the PHP code isn't negligible, especially when dealing with billions of requests per day -- even a 1% increase in execution speed would be massive.
I was simply amazed that Facebook has been running interpreted PHP all this time -- it's definitely not the fastest (or prettiest) language in the west. We'll have to wait until Tuesday to find out exactly what they've done, but I have a feeling Facebook might finally cease to be the slowest website on the Internet.
And yes, if you were wondering, Facebook is going to honor PHP's open source license and contribute their new code to the repository!













Comments
15
Subscribe to commentsJonathon HibbardFeb 1st 2010 9:40AM
While I will say that there are all sorts of solutions out on the net, I can't say that this is PHP's fault as much as the developer's fault.
Don't get me wrong, I realize that Facebook is perhaps the *largest* social networking site on the internet. However, they still have developers who run the schemas that this website is generated off of. I've also seen Facebook's runtime model they use for publishing their pages, but I personally think it's their model that is flawed.
They make way too many requests, and the manner in which they deliver their content is not optimal. But the fact remains that companies end up out-growing languages they used to initially get their name out on the block, just as Google wrote their own versions that could better server their own personal needs.
I've said this many times, and I'll say it again: It isn't the language that holds a company, website, or arch. back, it's the developers themsevles. One can only do what one understands from a language. Had this been .NET, Ruby, Python, Perl, etc, you would probably be hearing the exact same thing happening again, and this is mainly because they have found that the model they built their framework around isn't working at the optimal speed.
But for the author to say "was simply amazed that Facebook has been running interpreted PHP all this time -- it's definitely not the fastest (or prettiest) language in the west.", it just goes to show this author's misunderstanding of PHP or any other language for that matter.
PHP is not the fastest, it's not the prettiest, but no language truly is either. It's only as FAST and PRETTY as the developer him/herself makes it! Not what fanboys say is faster or prettier.
Sebastian AnthonyFeb 1st 2010 10:46AM
I like the way you told me off for calling it not the fastest or the prettiest... and then agreed with it in your next sentence.
What am I a fanboy of exactly?
The rest of your comment was interesting though!
Jonathon HibbardFeb 1st 2010 11:01AM
Sebastian,
I sense a baiting attempt here, but I'll bite this once. I dunno what you are a fan boy of, and I wasn't saying you were. I was saying in general, when you ask a developer of a particular language which is better, obviously that developer is going to side with what they know: which they should! And that's because that's what they know best to provide the best solution.
Secondly, I did say PHP wasn't the prettiest or fastest, but my point is that none are. Your post reeks of singling PHP out, from your article's title, all the way through your post. You even go so far as to say that maybe Facebook won't be slowest website on the internet once they get away from PHP.
So, I hope this answers your questions. If you can't take the heat of being corrected, do the work authors are suposed to do when they publish something like this for such a huge audience: DO SOME RESEARCH! :)
felipeFeb 13th 2010 10:32AM
The tool that built the facebook is a module that generates bytecode php code, using the same proposal for other languages like Python and Ruby. The goal is to end the reinterpretation of the system at each visit by the User. If facebook was already a great system agile and successful, now become the darling of the eyes of PHP developers. We hope that developers, as well as the project is available to the HipHop community participation, the developed product is also available.
__smooth__Feb 1st 2010 10:04AM
+1 on that!
3tearFeb 1st 2010 10:28AM
I can't seem to get PHP to run on my facebook page. :(
Sebastian AnthonyFeb 1st 2010 10:47AM
You're doing it all wrong!
3tearFeb 1st 2010 10:56AM
But I'm smarter and know more about PHP than all those stupid Facebook developers who are dumb cause I looked at their code.
Jonathon HibbardFeb 1st 2010 11:11AM
I never said I was smarter than the developers at Facebook. I do, however, stand by point that it's at the developer's code that speed is affected.
Any developer will tell you that when working, no matter if it's Facebook or Joe's Supermarket, when you work for a fast-paced company, they want solutions fast. They want them fast because that's what their audience calls for. But when we write the code fast, we sometimes make quick solutions rather than optimal solutions. And we end up saying "we'll fix this after we publish it. we'll make it faster!"...but that day doesn't come. And since our solutions "work", our bosses don't want to give us the time to make the necessary optimization changes that we, the developers, see and know need to be done.
But that happens everywhere, every day. If facebook held off on production of any other new features, could their developers find a faster way? OF course they could! That's why they went from being an ASP shop to being a PHP shop, because they gave them that time.
Either way, they're doing it again, except this time someone said "we should just build our own logic that adheres to own companies needs, not rely on a language that is meant for everyone. it's not personal enough to do what only we need". And that's what happens, even at google. it's part of evolving. I wish them luck.
AemonyFeb 1st 2010 11:58AM
I've never experienced Facebook as slow when browsing, but then it might be because I -only- have about 70 friends (real IRL friends, mind you) and I tend to block all those tiny little pointless applications that doesn't enhance the Facebook experience, but tend to spam your live feed.
And seriously, what's the deal with every single person accepting every friend request? People's definition of "friend" is rather weak when you have like about 90 % of your "friend" list populated with people you only met once or twice.
Oh, and the post was a good read! I didn't know Facebook ran on PHP before.
darwinsurvivorFeb 1st 2010 12:39PM
As much as I hate PHP, If their PHP code is anything like their Javascript code, I don't think PHP is entirely to blame here.
AndrewFeb 1st 2010 12:59PM
A small clarification so that people who are reading this who don't know much about PHP have all the info.
Although PHP does not cache compiled files by default, I would be extremely surprised if there are any large websites out there running PHP that do not use eAccelerator, APC, or some other op-code caching extension.
Using either of those tools will cause the compiled versions of the PHP script to be stored on the system the first time it is accessed. From that point forward the compiled version will be used instead. Which is, needless to say, much faster. To say that PHP is always compiled or interpreted on every page load would be absolutely false. Incidentally, both those tools take about 20 minutes (or less) to install and configure.
If Facebook built a tool to do that then they are simply reinventing the wheel and instead should be contributing to the projects already out there. But I'm sure that they know that already. So what they are actually doing will be interesting to see.
e-sushi™Feb 1st 2010 11:53PM
One thing has to be clear: if PHP is "slow" to them, they are coding it wrong!
But if they think they can do better, they can always opt-out of php and create their own cgi-alike executable thingy to handle their requests.
Just my 2 cents... giving you a cherry to top it off: facebook has one of the worse codebases in the history of the internet. Maybe they should clean up their act before trying to imply that it's php. Bah, next they'll say it's their mySQL or what? * LOL *
RebeccaFeb 2nd 2010 9:31AM
There seems to me here a bit of confusion on the article's choice of words... Mainly because one does not see a BIG operation like facebook going "OK, we'll migrate ALL our stuff to another language".
What's more likely is that they will code up something to make regular PHP faster, mainly because the last lines of the article say, and I quote:
"And yes, if you were wondering, Facebook is going to honor PHP's open source license and contribute their new code to the repository".
Sebasian, are you really up to the challenge of writing about this sorts of things?
Sebastian AnthonyFeb 2nd 2010 9:35AM
Sushi -- that's probably what they are doing... but we'll see when they announce it today! (I'll go check the news sources in a moment.)
Rebecca -- I haven't a clue what you're talking about. You should re-read your comments before you submit them, just to make sure they make sense.