How good is PHP performance?

后端 未结 8 1022
你的背包
你的背包 2021-02-02 16:11

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! P

相关标签:
8条回答
  • 2021-02-02 16:23

    PHP's performance is fine. Unless you're designing 3d games, of course.

    1. The differences are both negligible and flame-bait. Because, really, is the Rubyism of "who cares if it's fast if it scales?" all that wrong? See #2 for an example of what slows you down.

    2. Anything that takes time. (Ironic, I know.) But really, it always depends on how you do what you do that takes the time. For instance, I can write two queries with nearly identical output but as much as a 2.5x speed increase with the better syntax/choices. By and large, the worst time-waster in a PHP script is file access ... thanks to hardware. So, the number of files you include/require slows down the script more than its contents does—especially when fragmented.

      By this simple system I've manipulated my own MVC framework to be nearly 10x the speed of a bare-boned CodeIgniter application; it's simpler and more minimalist, yes, but it should show that including 1 file, versus 1 per class, can make huge differences in speed.

    3. So long as its *AMP it's good, Linux servers will, or course, be faster. I've been satisfied with both my WAMP and LAMP system, despite vastly different hardware and software differences. (But the LAMP system is, in general, the fastest though the lesser in hardware.)

    0 讨论(0)
  • 2021-02-02 16:23

    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.

    0 讨论(0)
  • 2021-02-02 16:24

    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

    0 讨论(0)
  • 2021-02-02 16:27

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

    0 讨论(0)
  • 2021-02-02 16:29

    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.

    0 讨论(0)
  • 2021-02-02 16:30

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

    By that I mean that most performance issues with Websites are related 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 (e.g., 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 because it doesn't matter (compared to everything else).

    0 讨论(0)
提交回复
热议问题