On PHP and Scaling 245
jpkunst writes "Chris Shiflett at oreillynet.com summarizes (with lots of links) a discussion about scalability, brought about by Friendster's move from Java to PHP. Chris argues that PHP scales well, because it fits into the Web's fundamental architecture. 'I think PHP scales well because Apache scales well because the Web scales well. PHP doesn't try to reinvent the wheel; it simply tries to fit into the existing paradigm, and this is the beauty of it.' (The article is also available on Chris' own website.)"
A few things that could lead to scalability (Score:5, Interesting)
What's Really Going On Here... (Score:5, Interesting)
Who know what scales? (Score:3, Interesting)
PHP has a wide support for many RDBMS, APIs and Operating Systems, but it is only a Language. A language doesn't scale, it's the platform that scales.
That's why I see the PHP/Apache/Unix to scale far better than (for example) ASP/IIS/NT: The first platform can run from a PDA to a high-perfomance Minicomputer; The second can run from an I686 (pentium support was removed?) to the best PC-Architecture based computer you can buy. That's the difference: A wide option platform versus a closed option platform.
Probably, the first platform will have perfomance leaks and will not take every perfomance point from the machine it runs within, but its scalability potential resides that it can run in whatever you throw it at. Maybe J2EE or other platforms will run faster on the same hardware than PHP, but PHP will scale there and will be looking shoulder to shoulder to it.
That's why I don't like to valuate Scalability from the "speed" point of view, but the "where it runs" point of view.
Yahoo. (Score:5, Interesting)
I worked in a small shop developing web apps, and while it wasn't mission critical stuff like banking, it wasn't exactly brainless "dump data from MySQL" stuff either. I was lucky that my boss wasn't picky about languages. But if anyone I work with doubts the power and simplicity of PHP, I usually bring up Yahoo.
IMHO, PHP rocks. It's suitable for pretty much any and all web development. It can be used for quick hacks, or you can code it like a pro with objects and stuff.
Re:A few things that could lead to scalability (Score:5, Interesting)
Comment removed (Score:5, Interesting)
Re:A few things that could lead to scalability (Score:3, Interesting)
Re:scalability is a dead issue (Score:5, Interesting)
Yes, that is tempting. But, conversely, it's a very useful capability for small projects. For larger projects, you just need to ensure you have the discipline not to use the capabilities.
For instance, here [covcen.org.uk] is a site I developed in PHP using a strict model-view separation. There is direct linkage between view and controller and controller and model -- I couldn't be bothered to sort that out for a project of limited size like that one. In a larger project, I'd probably devise some kind of mechanism for that.
You can write unmaintanable code in any language you choose. Discipline is the key.
Re:scalability is a dead issue (Score:1, Interesting)
Sure you can toss more database servers at the task, but a little caching would often (app dependant, of course) give a significantly more efficient solution.
Real world examples? (Score:4, Interesting)
I think to settle this debate is a possible real-world example. Look at the story on the Jboss Nukes Project [onjava.com]. It explains the CPU utilization and speed of the PHP version and how moving to a J2EE implementation decreased the wait times dramatically.
Its difficult to argue with facts.
Re:A few things that could lead to scalability (Score:3, Interesting)
Re:What's Really Going On Here... (Score:2, Interesting)
Scalability is Not a Language Feature (Score:4, Interesting)
Scalability depends on how you write your code. If your algorithms are good, your system will scale, and if they aren't, it will not. Any language that doesn't let you write good algorithms cannot be expected to be generally useful, but I think neither PHP nor Java fall in that category.
Finally, I think scalability is really not what's important, but rather performance. When developing tailor-made applications, I only care if they requires more or fewer resources for the number of requests they actually get, not for higher or lower loads. Of course, for libraries, operating systems, etc. the argument is different.
Re:jsp is a bad idea, but Java is not (Score:5, Interesting)
Tapestry for the view, Spring for the control, and Hibernate for the model is a combination hard to beat with php. Sooner or later all these technologies will be used no matter what underlying language.
Re:Author seems to live in a vacuum (Score:3, Interesting)
It's like comparing MySQL and Oracle; they both do largely the same thing, but Oracle's a lot more advanced and aimed a lot higher. From the article summary, it sounds like this guy just doesn't need that extra power. Good for him, I hope he's happy, but like you I don't share his low standards in languages -- my last few bits of web development have been with Ruby and FastCGI, and I'm not looking forward to my next bit of PHP maintainence.
Re:Real world examples? (Score:2, Interesting)
We know that the PetStore J2EE sample/reference application is ~10 times slower than a sample
We also know that the JBOSS people were sending false statements last year using anonymous accounts (around the time when the mentioned article was written).
So I would be very careful to state that "a J2EE implementation decreased the wait times dramatically".
I don't think so, not at all!
Re:Author seems to live in a vacuum (Score:1, Interesting)
PHP is itself a template language, so Smarty buys you nothing in that respect except another (badly-designed) pseudo-language to learn. When I used Smarty I had to drop down to PHP all the time and then it struck me how silly the whole thing was (my designer knows a little PHP, but was just confused by Smarty).
The output caching thing can be solved by a 5-line function that renders your PHP template, captures the output using the ob_* functions, and saves it to disk if it is stale. You can also create a hierarchy of dynamic sites and spider them (with wget, etc) to create a parallel hierarchy of static pages (I have used this for a customer that wanted fast static item pages in their ecommerce site.. it improved the site tremendously).
My "template rendering" code is barely one page of PHP, look how bloated Smarty is.
Some people benefit from Smarty, but my advice is, You Ain't Gonna Need It! Keep your code as *simple* as possible. Then when you need to add caching, it's easy to add.
Re:scalability is a dead issue (Score:3, Interesting)
An example was a project I "inherited" a few years back that was written with ASP for the presentation layer, business logic in COM objects, MS-SQL stored procedures for the database calls and MS-SQL for the backend database. It needed three developers to maintain all the different parts, and a simple change like displaying an existing database field on a web page meant changing code in three different places.
Debugging was also several orders of magnitude more complex - I remember the guys had a serious crash bug we were chasing for days, which we only solved by rewriting as a single ASP script with direct db calls so we see what the bloody thing was doing. Obviously we had access to the existing working multi-tier code as a base, but we did this in only a few hours.
Re:Yahoo. (Score:3, Interesting)