views:

879

answers:

9

This is a follow up to a recent post I've seen which suggests that PHP performance is poor:

"PHP. IS. ALWAYS. THE. BOTTLENECK. My server farms, let me show you them! PHP Overall Performance"

followed by:

"PHP performance is frickin' abysmal. I am basing this on my experience with OpenX (on Linux) and WordPress (on win64)."

Can we get some objective community input as to whether PHP performance is good, or bad ...

  1. Compared to other languages / runtimes
  2. From a language perspective, are there any specific libraries or operations which are better or worse than others?
  3. From a build perspective are there any versions, or platforms which are better or worse than others?
+2  A: 

PHP performance isn't so bad - compared to C, its going to lose out but compared to other scripting languages its roughly equal.

See this shootout for an interactive performance benchmark test to give you an idea of some performance metrics.

Of course, there's this slideshow that says PHP is rarely the bottleneck.

gbjbaanb
-1 for pointing to mid 2008 measurements instead of this weeks measurements http://shootout.alioth.debian.org/u32q/
igouy
but but but Google said ... thanks for the correction.
gbjbaanb
+2  A: 

Currently there is a project going on with the PHP developers to build better Benchmark tools for PHP.

The project leader did a talk recently on Google Techtalks called Compiling and Optimizing Scripting Languages, and it's a very interesting talk.

Also I did a PHP application size check the other day.

  • PHPBB 1.3mb
  • Joomla 6mb
  • Wordpress 11.3mb

That's data loaded into memory.

Ólafur Waage
+23  A: 

The answer to "How good is PHP performance?" is "Good enough".

By that I mean that most performance issues with Websites are relatd to other issues, like poor database design, little to no caching, CSS/Javascript/image caching and so on.

PHP is used by some of the largest sites on the Internet so it's passed that test. Jeff Atwood argues PHP Sucks, But It Doesn't Matter. There are things to rightly criticize PHP about (eg inconsistent parameter order, inconsistent function naming, magic quotes, etc) but I think he's overstating the negative.

So don't choose PHP (or not) based on supposed performance becuase it doesn't matter (compared to everything else).

cletus
+1 pretty much what I wanted to say but was too lazy to type
Paolo Bergantino
+1 indeed. If you need any indication that it's not the language at fault, look no further than facebook which I believe to be all php and has Google-like server load.
altCognito
Tom Martin
David Caunt
Its exactly the expierience i made. Usually the "bottleneck" will be the poor Database or too much or too stupid use of AJAX/ Javascript. E.g. the project of a colleague of mine has a BIG problem with all the javascript... our boss is just not understanding that its not a desktop app and u cant easiliy create new "windows" in your programm without loosing a lot of performance... But the solution of my colleague is poor too...
Gushiken
+3  A: 
The Wicked Flea
A: 

Using the correct algorithms and datastructures is much more relevant to the performance than using a certain programming language (as long as it's possible to express them in the chosen language).

So PHP can be even faster than C++ if the PHP-programmer knows what he's doing.

Dario
generally you find the C++ developer knows what he's doing more often than the PHP programmer. :)
gbjbaanb
A: 

Performance is greatly improved by using an op-code cache like The Alternative PHP Cache which is free and provides an significant performance increase by essentially "compiling" your scripts into op codes that can be used by the Zend Engine directly without the overhead (an overused term IMO) of parsing the code on each request. You can see a benchmark here and a post from my blog about using APC cache for speeding up Zend_Loader

Matthew Purdon
A: 

Yahoo! uses PHP. http://public.yahoo.com/bfrance/radwin/talks/yahoo-phpcon2002.htm

I disagree that PHP is always the bottleneck. PHP is as scalable and efficient as Java or ASP. At the end of the road it comes down to your database, the bottleneck will always start there.

Nael El Shawwa
A: 

PHP may not be as fast as compiled server side languages, but it is still pretty fast and does the job.

The "speed" aspect of php has more to do with the user experience than with the performance itself.

AJAX applications based on PHP don't get categorized as "slow" or "unresponsive": the user has so much to do while a single request completes! Also, being "uniformly slow" with all operations is much less painful for the user than showing having erratic performance speed.

One of the previous comments has summarized it quite aptly: language don't haz speed! the application doez.

cheers, jrh

Here Be Wolves
A: 

You might find these slides of a talk given by Rasmus somewhat relevant and interesting: talks.php.net/show/drupal08/

joedevon