Become a fan of Slashdot on Facebook

 



Forgot your password?
typodupeerror
×
PHP Programming IT Technology

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.)"
This discussion has been archived. No new comments can be posted.

On PHP and Scaling

Comments Filter:
  • by Dozix007 ( 690662 ) on Saturday July 03, 2004 @09:42AM (#9599558)
    PHP inherntely will not lead to scalability, however, if you ever try to create any applications that use a DFS-type algorithm, it can happen. PHP (I know it is web-based, shouldn't ask too much) does not allow for extremely simple soloutions in DFS type algorithms that are apparent to most users. Many will end up with too many "while()" statements and bring down script efficency exponetialy.
  • by TheNarrator ( 200498 ) on Saturday July 03, 2004 @09:52AM (#9599600)
    I've seen a friendster stack trace before, when the app was running slow at 5 am. For those of you who don't know what this is, it's when Java runs into an error and tells you were your program died. It was really funny. Basically there was a servlet and a call to Database.java and on line 8000 of database.java they were calling mysql directly. Real nice architecture, NOT!

  • by Lolaine ( 262966 ) on Saturday July 03, 2004 @09:55AM (#9599615)
    First of all; Everytime I see the term "Scalation", the narrator writes as If scalation was only a term for "bigger". We have to think not only of being bigger, but being smaller.

    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)

    by downbad ( 793562 ) on Saturday July 03, 2004 @09:58AM (#9599630)
    Yahoo is a prime example of PHP's scalability. Although they still use some legacy C code, nearly all of their new developments use PHP and BSD.

    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.

  • by Dozix007 ( 690662 ) on Saturday July 03, 2004 @10:04AM (#9599655)
    Depth-First-Search. You can use PHP to create a simple search engine by using arrays, fopen, fread, and while() loops. If done improperly, you can eventually loop your script into oblivion creating big time inefficency.
  • Comment removed (Score:5, Interesting)

    by account_deleted ( 4530225 ) on Saturday July 03, 2004 @10:12AM (#9599689)
    Comment removed based on user account deletion
  • by bigattichouse ( 527527 ) on Saturday July 03, 2004 @10:12AM (#9599690) Homepage
    Why not try term vector space? I've recently completed a PHP/Mysql term vector space engine (see website).
  • by julesh ( 229690 ) on Saturday July 03, 2004 @10:13AM (#9599694)
    developers will tend to munge sql calls into the templates, blow off any MVC separation, and get a system that is very hard to keep going for more than a few revisions.

    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.
  • by Anonymous Coward on Saturday July 03, 2004 @10:23AM (#9599731)
    My main issue with PHP scalability is the lack of a global context for app-level caching.

    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)

    by javab0y ( 708376 ) on Saturday July 03, 2004 @10:34AM (#9599778)

    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.

  • by Dozix007 ( 690662 ) on Saturday July 03, 2004 @10:57AM (#9599892)
    Actually... a web crawling script is quite small. I am not thinking in a Java mindset, but a CS one. Basic CS theory and knowledge can be applied most anywhere. PHP search scripts are quite usefull for internal site search, or a small network of sites. I also think that many should stop downing PHP as an unavaiable possibility for large projects. It is possible, you just need to be dynamic and well organized when doing so. A well coded site can work quite well, you just need to know what you are doing.
  • by higginsm2000 ( 242840 ) on Saturday July 03, 2004 @11:39AM (#9600053)
    It also means that there is a database access class with 8000 lines which is a scary thought...
  • by RAMMS+EIN ( 578166 ) on Saturday July 03, 2004 @12:30PM (#9600287) Homepage Journal
    While I am personally gratified that someone is making the case for PHP vs. Java, I think the whole idea of attributing scalability (as in, works for lesser and greater numbers) is wrong.

    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.
  • by caseih ( 160668 ) on Saturday July 03, 2004 @12:36PM (#9600322)
    Even better than JSP and other technologies is to use Jakarta's Tapestry as the presentation layer. Tapestry rocks and I look forward to having something like that on PHP. Right now PHPTal is close. The ability to define a page as components (almost in GUI terms) and then define event call-backs and so forth really makes life better.

    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.
  • by Fweeky ( 41046 ) on Saturday July 03, 2004 @01:08PM (#9600501) Homepage
    Well, you can make PHP which scales like crap and Java which scales as high as your bandwidth will allow, and vice versa. Java has architectural differences which make it potentially better suited to scaling high (both in terms of handling lots of users and in managing lots of complexity), but you need to have some clue to actually exploit them.

    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.
  • by Anonymous Coward on Saturday July 03, 2004 @01:49PM (#9600738)
    I would be extremly careful with such a statement.

    We know that the PetStore J2EE sample/reference application is ~10 times slower than a sample .NET implementation written by Oracle/Microsoft.

    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!
  • by Anonymous Coward on Saturday July 03, 2004 @03:06PM (#9601152)
    Smarty is an extra layer of complexity, I think a well-written site should avoid it.

    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.
  • by shut_up_man ( 450725 ) on Saturday July 03, 2004 @03:37PM (#9601297) Homepage
    I agree, but I've also seen the opposite - fairly simple projects completely buried in the complexity of multi-tiered architecture.

    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)

    by AmVidia HQ ( 572086 ) <gfung&me,com> on Saturday July 03, 2004 @06:33PM (#9602299) Homepage
    Ahem. You copied my comment I wrote some time ago. When you copy, give credit where it's due.

If a train station is a place where a train stops, what's a workstation?

Working...