Catch up on stories from the past week (and beyond) at the Slashdot story archive

 



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 Michalson ( 638911 ) on Saturday July 03, 2004 @09:47AM (#9599575)
    The only real argument I could really find was "Java doesn't do X well, therefore PHP must be great". The author seems to live in a universe with only two choices, his straw man Java, and his favorite web language, PHP. When he does try and argue PHP's merits on its own, it seems to collapse into a PHP is good because its good argument. I don't see any part of the article addressing how PHP can benefit the developer facing real issues of large scale web development (such as the need for caching systems on high volume websites, or the maintence challenge of larger code bases on complex sites). While good arguments may exist for PHP, they just don't seem to be here.
  • by DavidNWelton ( 142216 ) on Saturday July 03, 2004 @09:48AM (#9599582) Homepage
    Perhaps it's not mentioned very often because it's obvious, but I think it's an advantage for systems like PHP, or Rivet [apache.org] that they scale down very well.

    What does this mean? That they don't consume too much in the way of resources, and are very easy to get started with. This puts a dynamic web site within reach of more people, which is a good thing, even if inevitably some of them will, yes, write crappy code. It is another example of the "worse is better" philosophy.

    I just wish they had used Tcl or something else already out there instead of creating a language that in and of itself is nothing very exciting, and has been a bit slow.
  • Sorry buddy... (Score:1, Insightful)

    by Anonymous Coward on Saturday July 03, 2004 @09:53AM (#9599605)
    ... but scaleable enterprise systems just AREN'T written in PHP. It's a great language, and I can see where it has a niche, but it doesn't offer the same kind of power over distributed objects/systems that Java does. It's like comparing MySQL to Oracle for enterprise systems.
  • by Morgahastu ( 522162 ) <bshel ... fave bands name> on Saturday July 03, 2004 @09:53AM (#9599608) Journal
    I think the term is subjectable depending on the context in which it's used. Scalalable does have many definitions but I don't think that they are all wrong except for one.

    His definition suits him well but it might not be helpful for me.

    I might use scalable just to say that an application can easily (with little or no modification) handle 100x more users. This doesn't necessarily mean that the difference in system load varies a minimal specific amount per each extra request. All that matters is that it will work with higher demand. Who cares how or why.

    I think scalable can also mean that an app can handle 10,000 users when hosted on a single machine but when put on a cluster of computers it can handle exponentially more users. To me that is a scalable application.

    Scalable has no set definition in the contexts of applications.
  • by jenkin sear ( 28765 ) * on Saturday July 03, 2004 @09:54AM (#9599611) Homepage Journal
    Scalability is rarely that much of an issue- any halfway decent architecture (php, java, even .net) will let you scale horizontally- and Moore's law will take care of any performance problems in time.

    My big issue with PHP is maintainability- I see it (perhaps incorrectly) as a glorified templating language, which places it on the same evolutionary track as ASP and cold fusion; 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.
  • by Dozix007 ( 690662 ) on Saturday July 03, 2004 @09:57AM (#9599628)
    It is not a good thing that there is a short learning curve on PHP. While it does put the ability for dynamic webcontent at the fingers of most users, it also creates a crapflood of insecure sites. Not to mention when a user may get into more advanced PHP programming and know nothing of basic CS (I know, not a big CS language, but some things must be known). Inefficent scripts will bog down sites, improper loops and insecurity can wreak havok on a network. I have recieved several emails in relation to a PHP security project [slashdot.org] that I run from university admins who have difficulty with insecure PHP coders and allowing them to have access to PHP servers and SQL databases that others use.
  • by Anonymous Coward on Saturday July 03, 2004 @09:59AM (#9599639)
    you are correct that you are incorrect.... if anything, developers are moving towards MVC, like Mojavi [mojavi.org] - probably PHP's best MVC framework because it doesn't try to port struts to PHP, it writes a very flexible framework using PHP the way it was meant to be used.

    Also, maintainability is not a feature of a language, it's the organization practices of the developer. Java developers are used to throwing files wherever, doing import statements wherever, and once its compiled, it's organized! Well, you have to organize your files a little bit better in PHP for higher performing code. But hey, if you're sloppy then that's your fault, not PHP's fault it's just one of the aspect of a scripting language just like waiting around for compiling is an aspect of a compiled language.
  • by julesh ( 229690 ) on Saturday July 03, 2004 @10:00AM (#9599644)
    Sorry, your abbreviations are confusing me. DFS? I know Disk File System and Distributed File System, but neither of those seem a good fit for what you're talking about. So... what are you talking about?
  • by Christianfreak ( 100697 ) on Saturday July 03, 2004 @10:04AM (#9599658) Homepage Journal
    PHP's problem is that it quickly becomes unmaintainable in larger projects. That's why it doesn't scale, not because the platform isn't fast enough or Apache can/can't scale.

    PHP will continue to have this problem until someone comes and tells the developers about a nifty invention called 'namespaces'

    Some other things that could help: Standard templating for easier separation of design/content from code, a better module architecture that doesn't require me to recompile just to get some new functionality, some nice standard modules that go with that new architecture.

    Of course if someone did all of that you'd have Perl and since we already have Perl, I'll stick with it.
  • by Anonymous Coward on Saturday July 03, 2004 @10:05AM (#9599661)
    You can do ugly things using any languaje/patform it depends on the programmer
  • by bigattichouse ( 527527 ) on Saturday July 03, 2004 @10:15AM (#9599701) Homepage
    One of the great boons of PHP is the fact that you can build shell scripts with it. This allowed me to create a large distribution/inventory/control system in PHP, AND do all the back end processing in PHP as well. Sound inefficient, sure, but it works like a champ - plus any new programmers get to learn the system quite quickly due to consistency.
  • The reason (Score:2, Insightful)

    by Diclophis ( 203740 ) on Saturday July 03, 2004 @10:18AM (#9599715) Homepage
    HTTP URL Wrappers and file_get_contents and serialize, unserialize. With these functions alone you can recreate any CORBA SOAP XML-RPC type remoting. And remoting is good for for scalability because it lets you 'outsource' the workload to another machine. Truly N-Tier design (N>3).
  • PHP only becomes unmaintainable if you don't know what you're doing, or if you don't plan well at the onset. The thing about PHP is that it doesn't force you to do anything, which means it doesn't force you to do anything the right way. This is not a fault. I wouldn't be a PHP developer today were it not for the ease with which I learned to write some very, very bad code. Of course, there's room to grow. The result is that the onus is on the developer, and not the language. So you're right, PHP doesn't scale. Not it's job. PHP provides the opportunity to scale, and the toolset, which are more than adequate, and improving over time.

    This is particularly funny coming from a perl developer. Perl can become unmaintainable on a small project.
  • by sfjoe ( 470510 ) on Saturday July 03, 2004 @11:42AM (#9600061)
    1. PHP scales well.
    2. Java scales well.
    3. Friendster couldn't devlop a scalable J2EE application, so they switched to PHP.
    4. WHat will Friendster switch to when they can't develop a scalable PHP application?

  • Re:Sorry buddy... (Score:2, Insightful)

    by Zefram ( 49209 ) on Saturday July 03, 2004 @11:49AM (#9600098) Homepage
    The mistake you're making is to think that the language is going to magically fix all sorts of problems, and without this magic you're up shit's creek.

    JavaBeans are great in that they're an architecture to communicate through multiple levels and allow for separate tiers. But to think that the same thing can't be done in PHP is foolish. PHP is about keeping the language simple only giving the developer the tools he needs to get work done; making easy things easy, and hard things easier.

    I've written a system (propreitary, sorry) that has a complete separation among the 3 (or more) tiers, that allows retrieval of remote objects and combining that with local objects. It allows a user's session to be shared amongst a round-robin server farm, abstracted data access, and my very own templating system.

    The language is the lesser issues: it's the developers working on a piece of software and the design of the system that's important.

    Zef
  • by zangdesign ( 462534 ) on Saturday July 03, 2004 @12:38PM (#9600331) Journal
    It is not a good thing that there is a short learning curve on PHP. While it does put the ability for dynamic webcontent at the fingers of most users, it also creates a crapflood of insecure sites.

    I hate to say it, but the problem exists between keyboard and chair. PHP is not inherently secure or insecure language. It may still have bugs, but those are a function of age and the serious ones have been taken care of. Rather, the problem is in the way people write software using PHP, without necessarily understanding the nature of the platform they are using.

    It is not the job of the language to enforce security - it is the job of the programmer.
  • by jtheory ( 626492 ) on Saturday July 03, 2004 @01:29PM (#9600594) Homepage Journal
    I don't see any part of the article addressing how PHP can benefit the developer facing real issues of large scale web development

    I always tend to think of *accessing data* as where the rubber hits the road in website scalability. Of course, PHP by itself is super-scalable (because each request processing is independant)... but what exactly are you *doing* in that PHP code? If you aren't accessing and displaying data (generally from a database), you've got a pretty unique website.

    I don't see much point in discussing scalability if you're pretending these other layers don't exist... the scalability of a website based on PHP, Java, or whatever is only as good as the least scalable element... which is usually not the basic execution of the code, in the average website. That's the part that's easy to make scalable.
  • by tshak ( 173364 ) on Saturday July 03, 2004 @02:24PM (#9600944) Homepage
    It's also good to determine how scalable the code is. Is the code readable? Maintainable? Extensible? Can large teams effectively work on the same code base?

    While this does have more to do with how the code is written, programming languages to contribute to code scalability.

    Does PHP promote scalable code?
  • by Ogerman ( 136333 ) on Saturday July 03, 2004 @03:43PM (#9601326)
    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.

    Yes, PHP is excellent for web development. Yes, PHP can scale to even some large web sites. But since the web is still all the rage, this is unfortunately all that many people think about. Where PHP stumbles is when you need to move off the web or when you need to write complex business logic that is not solely driven by a web tier. PHP also fails when you need to integrate diverse transactional resources in an efficient manner. Not all business applications can be suitably implemented in PHP. As examples:

    - PHP, by its scripted execute-and-terminate nature, cannot schedule the execution of tasks on its own. So, for example, there is no way to schedule an email to be sent at a specified time. If you need this sort of functionality, you'll have to look beyond PHP to ugly hacks like cron jobs that call PHP. (and then PHP scripts that can automatically modify your cron scripts..) Alternatively, you could write your own scheduler in a different language.

    - Somewhat related, PHP is incapable of asynchronous operation. Suppose, for example, that we have a flood of customers placing orders. Our inventory database is fully capable of keeping up with the demand, but credit card processing system is backlogged and this is out of our control. So we cannot give users an immediate response as to whether their payment was accepted upon placing the order. We also don't want to make them wait 5-10 minutes after hitting the "place order" button for a response. The proper business solution is to accept the order, but send the customer an email later if the payment was rejected. This process requires asychronous operation -- queueing of the payment validation requests and possible further action separate from user interaction. PHP has no solution for this scenario or the many others like it and thus we must look beyond the PHP domain.

    - PHP is quite weak when it comes to writing a complex business logic layer. This is not to say that it is not possible, but there are no frameworks available comparable to those offered in the Java world (and I'm not just talking about EJB, btw). So this is not a question of languages, but of available tools to do the job efficiently. For example, PHP has no concept of application-level transaction management. (declarative transactions, isolation levels, etc.) Looking towards the cutting edge, it has no support for Aspect Oriented Programming, which is an enormous boon to business logic developers, available in Java, C++, .NET and others.

    - PHP is weak on tools for developing the persistence layer. For example, it has nothing comparable to Hibernate, let alone tools for RAD employing UML.

    - PHP has no pre-built solutions for caching persistent data, and certainly not objects. Once again, it is possible, but developers are left to roll their own solutions using shm extensions or writing out to the database backend. Using the database can be terribly slow and even the shm approach requires (de-)serialization on script load/terminate. While this sort of thing does not limit scalability, it does limit performance (response times).

    - PHP has no means of replicating application state in a cluster other than using the backend database. While this is often of no consequence, some complex business software holds a fair amount of state which needs not be persistent.

    - PHP itself cannot reasonably be used to develop non-web clients such as a GUI tool for efficient rapid data entry or greater interactivity, a PDA client, or an embedded device that interfaces with a campus security system. These sorts of clients can talk to PHP scripts via SOAP extensions, but it should be recognized that we have again left the PHP domain to meet these needs and the resulting solution may not be the most efficient.

    So in closing, PHP is great for some thing
  • by smitty45 ( 657682 ) on Sunday July 04, 2004 @11:14AM (#9605877)
    "since they simply converted their JSPs to PHPs and called it good."

    naw.

    friendster's load characteristics have to be totally uncacheable, because of how many users they have, and the amount of disparate data sources needed for the pages. no other social networking site has even close to their load.

    update a friend ? needs to be instantaneous. what happens then ? just about everyone on the entire system's friend count must change, real-time, with 1st, 2nd, and 3rd degrees. that means every addition/delete of a friend will effect hundreds of thousands of users to be correct.

    JSP or PHP, it doesn't matter...like I said before, social networking sites have many different things happening than other high-volume database sites.

Get hold of portable property. -- Charles Dickens, "Great Expectations"

Working...