Slashdot Mirror


On PHP and Scaling

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.)"

245 comments

  1. A few things that could lead to scalability by Dozix007 · · Score: 5, Interesting

    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.

    1. Re:A few things that could lead to scalability by Dozix007 · · Score: 1, Informative

      *Will Inherently Lead to Scalability* (Damn, can't type this early)

    2. Re:A few things that could lead to scalability by julesh · · Score: 3, Insightful

      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?

    3. Re:A few things that could lead to scalability by Dozix007 · · Score: 5, Interesting

      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.

    4. Re:A few things that could lead to scalability by Anonymous Coward · · Score: 2, Informative

      You're not thinking in a PHP architecture.... thinking Java style J2EE does not apply to using PHP.

      What is a PHP "server"... it is the combination of Apache and PHP and a request being served. Since the web is stateless with simple session IDs tying things together it's not really necessary to share memory or resources between requests... hence Rasmus Lerdorf's "share nothing architecture."

      It doesn't make sense do an olympic-sized web crawling script, and certainly not invoke it in the time of a web request. It makes more sense to write a script that is spawned by cron, with probably multiple instances that divy up the task of doing the search and creating the index.

    5. Re:A few things that could lead to scalability by bigattichouse · · Score: 2, Interesting

      Why not try term vector space? I've recently completed a PHP/Mysql term vector space engine (see website).

      --
      meh
    6. Re:A few things that could lead to scalability by Dozix007 · · Score: 3, Interesting

      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.

    7. Re:A few things that could lead to scalability by mindstrm · · Score: 1

      Okay, but this is irrelevant to the article. You can implment something badly in any language.

      I think you would be surprised how many large projects use PHP very successfully.

      I don't know anyone who has ever used PHP for an internal site search.. especially in a large project environment. Searches belong to databases.

    8. Re:A few things that could lead to scalability by shokk · · Score: 1

      And this improper action cannot be done with other programming languages?

      --
      "Beware of he who would deny you access to information, for in his heart, he dreams himself your master."
  2. Gah, no! by DrEldarion · · Score: 4, Funny

    it simply tries to fit into the existing paradigm

    Allright, he used the word "paradigm", that makes his opinion automatically invalid.

    1. Re:Gah, no! by Prowl · · Score: 5, Funny

      but he didn't use the phrase "paradigm shift", so we could give him the benefit of the doubt

      --
      That man tried to kill mah Daddy
    2. Re:Gah, no! by Anonymous Coward · · Score: 0

      paradigm.. paridigmish? I know what that means.. I swear! I used it in high school.

      nous paradigmons
      vous paradigmez
      ils paradigment

      see? SEE?!

    3. Re:Gah, no! by azuretek · · Score: 1

      must be a typo

    4. Re:Gah, no! by beebware · · Score: 1

      But, basically, at the end of the day - we do need to achieve synergy to ensure that long term goals are made.

    5. Re:Gah, no! by telstar · · Score: 1
      "but he didn't use the phrase "paradigm shift", so we could give him the benefit of the doubt"
      • Way to think outside the box!!!

      • </sarcasm>

    6. Re:Gah, no! by julesh · · Score: 1

      Yeah, but nobody pronounced "ils paradigment" right, but the teacher let it slip anyway, cause he couldn't be bothered to explain why it isn't pronounced that way.

  3. Author seems to live in a vacuum by Michalson · · Score: 5, Insightful

    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.

    1. Re:Author seems to live in a vacuum by lamz · · Score: 5, Informative
      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).

      The article doesn't mention it, but Smarty is an excellent PHP library that implements, among other things, caching. I have used it extensively with excellent results.

      --

      Mike van Lammeren
      It will challenge your head, your brain, and your mind.

    2. Re:Author seems to live in a vacuum by RAMMS+EIN · · Score: 1

      "Java doesn't do X well, therefore PHP must be great"

      But then, how can you conclude a language scales well, other than by comparing it? Java is supposedly used by so many sites that it can be used as a measuring standard. If PHP scales better, it must be great. I think that sounds quite reasonable.

      For the record, I like neither language that much. I use PHP every day, but I would rather be using Python or LISP.

      --
      Please correct me if I got my facts wrong.
    3. Re:Author seems to live in a vacuum by smitty45 · · Score: 1

      Did you read all of the authors opinions ? I see many good reasons for right tool for the right job listed here, and Friendster is obviously one of them.

    4. Re:Author seems to live in a vacuum by Bluelive · · Score: 1

      Its worse than that, Because in their implementation java did share information on the server between connections and the php implementation did this less, the php version could be cloned over multiple servers. They could have done the same with the java implementation.

    5. Re:Author seems to live in a vacuum by dekeji · · Score: 1

      I don't see any part of the article addressing how PHP can benefit the developer facing real issues of large scale web development

      It does: the author talks about how PHP forces you to use scalable mechanisms for state management (in contrast to, say, Java).

      or the maintence challenge of larger code bases on complex sites

      Well, PHP generally requires much less code than Java to get the same task done, so that's another advantage for PHP.

    6. Re:Author seems to live in a vacuum by Fweeky · · Score: 2, Interesting

      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.

    7. Re:Author seems to live in a vacuum by claar · · Score: 4, Informative

      Um, this is an article about scaling, and therefore performance. Mentioning Smarty in such context is almost off-topic ;-)

      Personally, I find the lighter weight Savant to be a better choice, since it's straight PHP (No syntax to learn either -- bonus!). That removes the need for Smarty's "compile into php"
      step entirely, which has giving me MUCH better performance than when I was using Smarty. IMHO&experience, at least.

      (And if you want caching, it can be done at the PHP engine level rather than in your templating engine -- see any of the PHP accellerators out there)

      --
      I'd give my right arm to be ambidextrous...
    8. Re:Author seems to live in a vacuum by jtheory · · Score: 2, Insightful

      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.

      --
      There are only 10 types of people: those who understand decimal, those who don't, and, uh, 8 other types I forget.
    9. Re:Author seems to live in a vacuum by tolan-b · · Score: 2, Informative

      Quite. The advantage of Java when combined with a database (and as you rightly point out how often is a webapp *not* combined with a database?), is that you can take advantage of in memory caching, improving scaling up to a point by reducing load on the database, which is typically the slowest part of a web app transaction.

      Personally I use and love both Java and PHP for web apps, horses for courses certainly, but I would be far more comfortable with Java for a large webapp any day.

    10. Re:Author seems to live in a vacuum by aled · · Score: 1

      Well, PHP generally requires much less code than Java to get the same task done, so that's another advantage for PHP.
      Nice troll. How many lines of code takes multithreading in PHP? No luck here. How many lines to run in a smartcard? Nop. A Python interpreter in PHP? Niet.
      Use the right tool for the problem.

      --

      "I think this line is mostly filler"
    11. Re:Author seems to live in a vacuum by justMichael · · Score: 3, Informative

      Yes Smarty compiling the templates into PHP causes some overhead. Compiling templates only happens once (unless you modify the template) so I'm not sure why your performance numbers were so much better with Savant, maybe the config?

      But if you are running a site that can use the output caching that Smarty offers and the code is done properly, you will see huge speed increases as you can skip everything in the page including opening a db connection. Which gives very close to flat HTML performance.

      As to using PHP accelerators, they don't handle output caching by themselves. You can code your own, but my time is better spent doing other things ;)

      Using Smarty and Turck together is pretty impressive.

    12. Re:Author seems to live in a vacuum by Anonymous Coward · · Score: 1, Interesting

      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.

    13. Re:Author seems to live in a vacuum by Anonymous Coward · · Score: 1, Informative

      Actually, last time I checked (yesterday), Zend's Performance Suite Enterprise Edition includes both a PHP accelerator and does handle script output caching. Yes you can code your own, but then it depends how you like to spend your spare time... ;-)

    14. Re:Author seems to live in a vacuum by smagruder · · Score: 1

      He said "generally", and generally, he's correct with respect to web development.

      --
      Steve Magruder, Metro Foodist
    15. Re:Author seems to live in a vacuum by smitty45 · · Score: 1

      in Friendster's case, there's just no such thing as in-memory caching. it can't be done.

    16. Re:Author seems to live in a vacuum by smitty45 · · Score: 1

      seeing how they had pretty smart people writing the J2EE app they started with, I doubt that they didn't get it right with Java.

      When you have the authors of "Tomcat: The Definitive Guide", and "Mastering Tomcat Development" writing your app, then I would assume at the very least that they are as good as any other Java team.

      I think people should consider the possibility that Friendster has/had scaling issues that other sites plainly don't have. All of their pages have to be dynamic, and I doubt that any of barely 1% would be cachable, besides images.

      I also think that people should consider the possibility that they don't have any idea why Java didn't work for Friendster, because frankly, they don't. And your app is only going to be as good as the stuff behind it.

    17. Re:Author seems to live in a vacuum by aled · · Score: 1

      A little trolling of my part ;-) I know... but he started: "PHP forces you to use scalable mechanisms for state management (in contrast to, say, Java)". This is just flaming.

      Seriously: there is a very good argument around here in this post.

      --

      "I think this line is mostly filler"
    18. Re:Author seems to live in a vacuum by Safety+Cap · · Score: 1
      seeing how they had pretty smart people writing the J2EE app they started with, I doubt that they didn't get it right with Java.
      Unlikely. As they were able to port over quickly, we must conclude they were using a Model 1 model, rather than Model 2, since they simply converted their JSPs to PHPs and called it good.

      Other evidence leads us to the same conclusion: the use of "database.class" for calls, and the lack of (their words) "scalability" means they didn't have their business logic separate from the view.

      Most '733t h4xx0r5 don't get the MVC concept...and that's why PHP + mySql is so attractive to them.

      --
      Yeah, right.
    19. Re:Author seems to live in a vacuum by dekeji · · Score: 1

      This guy seems to troll all over the place.

      No, I just think. But go back and happily consume what people feed you: Java, iPod, Macintosh, multimedia plugins. All the really "hot", "cool", and "high-tech" stuff--some bimbo supermodel says so, after all. Just don't use your brain--you might accidentally generate a thought.

    20. Re:Author seems to live in a vacuum by dekeji · · Score: 1

      A little trolling of my part ;-) I know... but he started: "PHP forces you to use scalable mechanisms for state management (in contrast to, say, Java)".

      That is what the article said. It was in response to Michalson's claim that the article doesn't give any reasons for why PHP should be good for scalable web development.

      This is just flaming.

      No, flaming would be if I called you a "retard, incapable of reading comprehension at the elementary school level". Even if I had made an incorrect statement about PHP, it wouldn't amount to flaming. What I actually did was to paraphrase a statement from the article.

    21. Re:Author seems to live in a vacuum by greenrd · · Score: 1
      Tomcat is:

      (a) a servlet/JSP engine, not a fully-fledged J2EE container (like, say, JBoss)
      and (b) hardly the most efficient servlet engine on earth.

      Thus, the fact that an author knows a lot about Tomcat does not automatically imply that they know a lot about J2EE overall - or, indeed, scalability.

    22. Re:Author seems to live in a vacuum by smitty45 · · Score: 2, Insightful

      "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.

    23. Re:Author seems to live in a vacuum by tolan-b · · Score: 1

      They can't cache database accesses? Why not?

    24. Re:Author seems to live in a vacuum by smitty45 · · Score: 1

      because they have 10 million users, and each page will be different as users add and delete friends, over time.

      the likelihood of having a database query happen again anytime soon after is basically zero, because of the friend count changing.

    25. Re:Author seems to live in a vacuum by Fweeky · · Score: 1

      Smart and experienced people get things wrong too, especially when working on things where their normal techniques work poorly. I dare say they realised their old system was badly suited to their needs and needed a *lot* of work to put right, to the point at which it was cheaper just to rewrite from scratch in an easy language. That suggests to me their original software was pretty badly designed, even if that design would work well on a more traditional site.

    26. Re:Author seems to live in a vacuum by tolan-b · · Score: 1

      rubbish, there are all sorts of database queries that might be repeated, and the whole point of caching is that it takes advantage of the fact that recently accessed data is likely to be accessed again soon. not all 10 million users are going to be logged in at the same time...

    27. Re:Author seems to live in a vacuum by Anonymous Coward · · Score: 0
      the lack of (their words) "scalability" means they didn't have their business logic separate from the view.

      The rest of your comment at least makes a little sense, but that makes it seem like you have no idea what scalability means. Did you read the article? Separating business logic from presentation is all about code cleanliness and maintainability and has nothing to do with scalability.

    28. Re:Author seems to live in a vacuum by smitty45 · · Score: 1

      you're not understanding.

      If my friend adds another friend, then my 2nd degree network just changed, and any query that will include my 2nd degree network (i.e. just about every search I could possibly do) and then that query is no longer cacheable. that happens thousands of times, within minutes.

      believe me, it's uncacheable.

    29. Re:Author seems to live in a vacuum by tolan-b · · Score: 1

      There are almost always significantly more reads from a system like this than writes.

      How many times is your second degree network likely to change within a 10 minute session?

    30. Re:Author seems to live in a vacuum by smitty45 · · Score: 1

      probably pretty likely, given the amount of traffic the site gets.

      But even if it didn't, it's much more likely that my 3rd degree network will change, given that it's about 77,000 people. All user/interest searches are within your network, depending on the search criteria. (2nd, 3rd, or everyone), and the default is 2nd degree.

      Also, with mysql, each read is going to be a write anyway. I'm not arguing that there is zero caching going on, just not much to be significant at all.

    31. Re:Author seems to live in a vacuum by tolan-b · · Score: 1

      Let's say we have a million people, say we need to keep 2k of data for each person in memory for most purposes (ie. id, name, image url, 1st level relationships, more would need to be loaded for people currently logged in of course, but they're a minority). You can keep all that information in memory in under 2gig... not exactly out of reach of a company like friendster. you don't have to load all the data about a person into memory for it to be useful for reducing database access for a large number of tasks significantly.

    32. Re:Author seems to live in a vacuum by smitty45 · · Score: 1

      understood, but the calculation and re-lookup needs to happen *each time* in order to be current.

      also...messages and testimonials (i.e. that are displayed on every profile page) I doubt would fit into that footprint.

      the profile page on friendster does your friend count, lists you friends, and any searching is within your network, which is affected by the use of other users on the network.

      -every time someone might change their profile...your search criteria would presumably change, and therefore the data
      -every time someone adds a friend who is up to 3 degrees from you...your data changes again

      image url is probably the only thing that doesn't change depending on the use of other people.

    33. Re:Author seems to live in a vacuum by aled · · Score: 1

      You right me bad. I misunderstud your previous post.

      --

      "I think this line is mostly filler"
  4. PHP scales down, too by DavidNWelton · · Score: 4, Insightful

    Perhaps it's not mentioned very often because it's obvious, but I think it's an advantage for systems like PHP, or Rivet 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.

    1. Re:PHP scales down, too by Anonymous Coward · · Score: 3, Funny
      You're right.

      however, if you wrote the same thing about Visual Basic / ASP, you would have been modded a troll.

    2. Re:PHP scales down, too by Anonymous Coward · · Score: 0

      I see your ASP and rise by an IIS worm. Visual Basic just sucks.

  5. Another article by Anonymous Coward · · Score: 4, Informative

    Here's an article from Jack Herrington on PHP's scalability.

    http://www.onjava.com/pub/a/onjava/2003/10/15/ph p_ scalability.html

  6. jsp is a bad idea, but Java is not by ahmetaa · · Score: 5, Informative

    if someone wants to produce a high performance web site in Java, jsp is a bad choice. use Velocity - pure java objects - a decent DB abstraction mechanism (Hibernate, iBatis). . Plus, i used php, ok, it is easy to use and can be preferred small to medium size web sites. but call me biased, it is nowhere near the elegance of java.

    1. Re:jsp is a bad idea, but Java is not by Anonymous Coward · · Score: 0

      You're biased.

    2. Re:jsp is a bad idea, but Java is not by Anonymous Coward · · Score: 2, Insightful

      You can do ugly things using any languaje/patform it depends on the programmer

    3. Re:jsp is a bad idea, but Java is not by julesh · · Score: 1

      Correct me if I'm wrong, but isn't JSP just a simplified syntax for creating servlets by embedding Java code withing an HTML document?

      If so, why should this cause performance problems?

      (As an aside, I've run a JSP server in the past on a 100MHz pentium, and after the first use of each page performance was OK, so I'm not sure what the big problem is...)

    4. Re:jsp is a bad idea, but Java is not by Decaff · · Score: 2, Informative

      The problems with JSP are to do with writing maintainable code, not speed. There is a principle of software development that suggests that it is a bad idea to embed software logic in presentation code, as this does not allow for easy modification. If you support this principle, JSP (and some ways of using PHP) are not a good idea. However, JSP is not slow: the JSP pages are translated into Java Servlet source code and then compiled. This can result is very fast websites.

    5. Re:jsp is a bad idea, but Java is not by javab0y · · Score: 2, Informative

      No...you are not correct. Your point about JSPs is only this is only true under a model 1 implementation/design. A model 2 implementation (where your business logic is done in Java objects) utilizes JSPs exactly like Velocity...only as a template. See Struts and other MVC frameworks that embrace a model 2 implmentation of JSPs.

    6. Re:jsp is a bad idea, but Java is not by mabinogi · · Score: 3, Informative

      JSP on it's OWN is a bad idea.

      just as Velocity on it's own would be a bad idea.
      Write your buisness logic in plain java, use servlets to manage the flow of control, and to call your java API to create value objects (beans) to place in the request, and then use JSP to format the data.

      You only run in to problems if you try to do everything with JSP, which is always a bad idea, just as it's always a bad idea.

      and JSP 2.0 is even better with the JSTL expression language built in.

      --
      Advanced users are users too!
    7. Re:jsp is a bad idea, but Java is not by Decaff · · Score: 1

      No...you are not correct. Your point about JSPs is only this is only true under a model 1 implementation/design.

      You are right - I was talking only about model 1. JSPs can be used very effectively in MVC frameworks.

      What I was trying to describe was JSP use when Java code is embedded, rather than tag libraries.

    8. Re:jsp is a bad idea, but Java is not by gl4ss · · Score: 1

      thats what it is(on first run they're compiled into something like 'normal' servlets)... but then again the guy didn't really give out any reason why jsp's are a bad idea so it's highly possible he didn't know anything about them.

      --
      world was created 5 seconds before this post as it is.
    9. Re:jsp is a bad idea, but Java is not by caseih · · Score: 4, Interesting

      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.

    10. Re:jsp is a bad idea, but Java is not by tweek · · Score: 1

      We just wish hibernate had connection pooling that supported reconnects.

      Right now our developers work on tomcat and part of our ant script modifies hibernate.xml to use Websphere's connection pooling via JNDI. I'm not sure if they've modified the dev environment to use JNDI yet.

      Then again I'm just the Sr. Sysadmin on the project. The real greese are the developers and trust me, we've got some good ones. Hell, one of em wrote the book on struts =P

      I do wish PHP had something like Struts though. When I had Holmes explain it to me, I was floored. It's not the be all and end all but it's damn cool. Hibernate, however, is a beast on its first usage.

      I still prefere PHP's adodb myself.

      --
      "Fighting the underpants gnomes since 1998!" "Bruce Schneier knows the state of schroedinger's cat"
    11. Re:jsp is a bad idea, but Java is not by Anonymous Coward · · Score: 0

      I know that ORM is pretty popular right now, but it's a bad idea. All you end up doing is papering over the most important layer of your application, the db access layer, and trying to pretend you're manipulating objects.

      Instead of doing that, why not learn how to use the dbms the way it was intended to be used, natively? Learn SQL well, not as a metaphor for objects. Learn how to optimize queries; don't just throw in some caching layer on top of your slow SQL queries and pretend you've solved anything. Instead, all you done is trade data freshness for speed, badly, and introduced state into your app server.

      I'm writing a JSP app right now, and it screams. I'm using the sql tags of the jstl, and not EJB or hibernate or any other excessive hide-the-database layer. The reason it screams is that I tune my queries. No matter how hard the query, I don't leave it until it's under a second. Some of them start out at 4 minutes!

    12. Re:jsp is a bad idea, but Java is not by Tony-A · · Score: 1

      Instead of doing that, why not learn how to use the dbms the way it was intended to be used, natively? Learn SQL well, not as a metaphor for objects. Learn how to optimize queries; don't just throw in some caching layer on top of your slow SQL queries and pretend you've solved anything. Instead, all you done is trade data freshness for speed, badly, and introduced state into your app server.

      Probably the best advice in this whole mess.

    13. Re:jsp is a bad idea, but Java is not by caseih · · Score: 1

      Personally I really dislike struts. It serves its purpose when you are working within the JSP framework. But ditching JSP entirely is a great thing. That's what tapestry does.

    14. Re:jsp is a bad idea, but Java is not by archangel77 · · Score: 1

      If you look for something like Struts for PHP, you can have a look at Phrame. They tried to come very close to Struts.
      If you look for somthing like Hibernate for PHP you can look at Propel.

  7. What's Really Going On Here... by TheNarrator · · Score: 4, Interesting

    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!

    1. Re:What's Really Going On Here... by Morgahastu · · Score: 1

      And?

    2. Re:What's Really Going On Here... by aled · · Score: 1

      Only proves that:
      -friendster programmers don't know how to catch an error in Java, something that Java has plenty ways to do.
      -is easy to find where the error is in Java. I've seen lot's of "Warning: MySQL Connection Failed: Unknown MySQL error in /www/something.php on line nn" so it is a similar thing with PHP. The stack trace makes usually easier to the programmer to find the problem but it should not be shown to the user.

      --

      "I think this line is mostly filler"
    3. Re:What's Really Going On Here... by julesh · · Score: 2, Informative

      What do you mean "calling mysql directly"? I can assure you that isn't actually possible in Java. MySQL is a C application, Java can't call C code without some kind of intermediate layer.

      Also, what's "Database.java" -- if it's part of the MySQL/Java interface layer, this would be perfectly appropriate behaviour.

    4. Re:What's Really Going On Here... by Anonymous Coward · · Score: 0
      Basically there was a servlet and a call to Database.java and on line 8000 of database.java they were calling mysql directly

      Does this mean they were invoking the mysql executable via system() or exec() or similar? Or are you saying that each page view hits the database whether it needs to or not, i.e. are you saying that there is no layer to cache commonly used info? Both are bad, but not caching is probably not too terrible a plan if mysql is fast enough. (It should do some caching of its own, although not at the speed you'd get if you cached within the application.)

    5. Re:What's Really Going On Here... by Anonymous Coward · · Score: 0

      Oh no, they were calling mySQL directly! Who cares? They probably never intended to port to any other database?

      If they had a "DB abstraction layer" the thing would've been even slower.

    6. Re:What's Really Going On Here... by Decaff · · Score: 1

      If they had a "DB abstraction layer" the thing would've been even slower.

      No, as such abstraction layers can cache results, store compiled queries etc.

      A few more method calls between your code and the database is going to make no difference whatsoever on modern hardware.

    7. Re:What's Really Going On Here... by julesh · · Score: 1

      As far as I'm aware, Java enforces the use of a database abstraction layer. It's called 'JDBC' and is in the package java.sql. If they're using JDBC then switching to another database server would be a matter of changing the contents of two strings (and ensuring compatibility of their data schemas and queries, but that's a problem however you do it).

      I'm not aware of any other way to access MySQL from a Java application.

    8. Re:What's Really Going On Here... by cygnus · · Score: 1

      /me slaps forehead. no, that was the MYSQL JDBC driver you saw in the stack trace. JDBC is a database-agnostic plugin architecture for communicating with databases that abstracts away a lot of the stuff that makes talking to a database a "to the metal" task. it's like pear_db, only you don't have to hope that your ISP included it when it was compiling PHP. you just plop some JARs in your web application and chug.

      --
      Just raise the taxes on crack.
    9. Re:What's Really Going On Here... by fimbulvetr · · Score: 1

      Hey, pay attention.

      Warning: MySQL Connection Failed: Unknown MySQL error in /www/something.php on line nn

      That's a mysql error. I've worked with php since early 3.x, and I've NEVER seen an unknown error.

    10. Re:What's Really Going On Here... by TheNarrator · · Score: 1

      Just to clarify, IMHO their architecture appeared to be jsp model 1 architecture which IMHO is not a very performance oriented architecture. They could have at least used jsp model 2 and used various caching layers for business objects,etc.

    11. Re:What's Really Going On Here... by higginsm2000 · · Score: 2, Interesting

      It also means that there is a database access class with 8000 lines which is a scary thought...

    12. Re:What's Really Going On Here... by aled · · Score: 1

      I just found 15000 hits in Google of "MySQL Connection Failed: Unknown MySQL". Many of those are down sites. Perhaps you are doing what they should do: catch errors.

      --

      "I think this line is mostly filler"
    13. Re:What's Really Going On Here... by Anonymous Coward · · Score: 0

      What I think the poster means is that the error was on like 8000 of a class. That is very poor OO design. There is absolutely no reason to have 8000 lines of code in one class. It means there are no objects, just calls to mysql from a class that basically put all the database code in one place (at least they went for reuse).

      It's not suprising that the site runs faster on PHP than this site ran on JSP with monkeys like that coding the thing.

    14. Re:What's Really Going On Here... by Anonymous Coward · · Score: 0

      The jdbc driver class is not called Database.java (it's called Statement, Connection, Driver etc). I've used the mysql databases, also I doubt the classes are 8000 lines long! That's insane.

    15. Re:What's Really Going On Here... by Anonymous Coward · · Score: 0

      That's not entirely true. I use OJB (http://db.apache.org/ojb) it complies the SQL for me, and knows how to speak to MySQL, Oracle, etc. It works very well for me not having to care about SQL (Which I hate)

    16. Re:What's Really Going On Here... by Anonymous Coward · · Score: 0

      Well, if all you can get to get your coding done is monkeys, then you need to get tools that monkeys can use. Java evidently is not that tool.

    17. Re:What's Really Going On Here... by Fweeky · · Score: 1

      I've seen PHP *functions* 1,000 lines long dealing with complex DB queries (and templating and such, *sigh*); an 8,000+ line Java class which appears to handle all interaction with a DB isn't that unlikely. Of course, if they're writing code that badly, PHP is probably better suited to their skill set. Ugh.

      As for accessing the db directly, maybe the parent means it does all the sockets and MySQL protocol stuff itself. *shrug*.

    18. Re:What's Really Going On Here... by vanza · · Score: 1
      What do you mean "calling mysql directly"? I can assure you that isn't actually possible in Java. MySQL is a C application, Java can't call C code without some kind of intermediate layer.

      Well, we could also argue that you couldn't do that in any language, since MySQL is a daemon and the client libraries will open a connection to the daemon to talk to it...

      Even if it were a JNI wrapper around the C libraries, that was not the point of the original poster. The point seems to be that there's a huge monolithical magical "Database.java" that seems to be were the DB logic is done. And it is called directly from the servlets, which are the entry points of the application. Really bad design. They are just using the servlets as a thin wrapper around SQL calls, which would make it nearly impossible to implement things like caching which would be trivial with a well done design.

      Also, what's "Database.java" -- if it's part of the MySQL/Java interface layer, this would be perfectly appropriate behaviour.

      Actually, that would be even worse, since it would imply that the servlets are talking directly to the database with no intermediate helper classes at all. Talk about code reuse!

      --
      Marcelo Vanzin
    19. Re:What's Really Going On Here... by fimbulvetr · · Score: 1

      My comment still stands. That is a mysql error, _not_ a php error.
      Mysql may have unknow errors, and they may happen all the time, but that's related to mysql and mysql's libraries. It's _not_ related to php.

      Php is delivering the error on behalf of mysql.

      Something like this:

      Would die with php spitting out the mysql error if mysql errored out.

    20. Re:What's Really Going On Here... by MntlChaos · · Score: 1

      If you would have looked, those were mostly "Unknown MySQL server host" errors. Searching for "MySQL Connection Failed: Unknown MySQL Error" yields a paltry 13 results, by comparison

    21. Re:What's Really Going On Here... by aled · · Score: 1

      I never say that's a PHP error. What I'm saying is that any DB error should not bomb in the face of the user like that, be that you program in ASP/PHP/JSP/Perl or whatever. That's bad style.
      My original post says that if one don't catch DB errors they explode more or less the same in any language.

      --

      "I think this line is mostly filler"
    22. Re:What's Really Going On Here... by danharan · · Score: 1

      Exactly. It's not the prettiest, but I've seen it happen too. Basically, all the DAO layer was in one file, but it had over 100 functions, all static. Oh, and Java/sql does make for a lot of boilerplate...

      I just refactored the whole thing so that we ended up with fewer files (e.g. InventoryDAO, UserDAO...). The only advantage was making things more intuitive for coders, and creating less locks with source control.

      In any case, 8000 lines for a single file is not a big deal maintenance-wise. I'd sooner have a system with a huge DAO than a bunch of PHP or JSP pages with no clear separation of concerns.

      --
      Information: "I want to be anthropomorphized"
    23. Re:What's Really Going On Here... by fimbulvetr · · Score: 1

      If that's the case, forgive me for misinterpreting your statement. It was my impression that you were slamming php for its error messages. If you wanna slam authors of (insert language here) for their error checking, then I'm on your side. PHP has quite good error checking, though not as nice as perls (i.e. runaway semicolon on line foo). The one you pointed out is a default ( or die(mysql_error()) ) in most cases.

      Hell, you can even slam mysql for having an error like "unknown error", and I'll rant with you.

    24. Re:What's Really Going On Here... by julesh · · Score: 1

      Yeah, but this is a layer on top of JDBC, I think. You're still using JDBC, but indirectly.

    25. Re:What's Really Going On Here... by Anonymous Coward · · Score: 0

      and friendster also ran a cluster of 90 tomcat servers. what a joke. bad code, bad container.. java is slow!

    26. Re:What's Really Going On Here... by HungSquirrel · · Score: 1

      Of course these errors shouldn't be visible to the user. However, it's up to you the developer to change the error output. PHP supports numerous different error reporting methods. Don't blame PHP for 'problems' that arise because you don't bother changing a default setting or two.

      PHP error handling and logging

      --
      $ whatis themeaningoflife
      themeaningoflife: not found
  8. Sorry buddy... by Anonymous Coward · · Score: 1, Insightful

    ... 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.

    1. Re:Sorry buddy... by julesh · · Score: 1

      That depends entirely on the complexity of the system you're trying to implement. Scalability has little to do with that. A very frequently used but simple application is probably better implemented in PHP than Java.

    2. Re:Sorry buddy... by Zefram · · Score: 2, Insightful

      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

      --
      What about MEEPT?!?!
    3. Re:Sorry buddy... by hotgazpacho · · Score: 4, Informative
      scaleable enterprise systems just AREN'T written in PHP
      Tell that to Yahoo!

      See their explanation on why they use PHP
    4. Re:Sorry buddy... by Anonymous Coward · · Score: 1, Informative
      Executive summary:
      • ASP/ColdFusion are ugly and expensive.
      • Java threading on FreeBSD sucks.
      • mod_perl has poor sandboxing.
      • PHP isn't particularly good, but it does meet our criteria.
    5. Re:Sorry buddy... by Anonymous Coward · · Score: 0

      You should have read the article. At least then you might know how to spell scalable (this is even mentioned in the first paragraph).

  9. Definition of Scalable by Morgahastu · · Score: 4, Insightful

    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.

    1. Re:Definition of Scalable by iamdrscience · · Score: 1

      This is just me being a grammar nazi, but you use the word "subjectable" in the first sentence of your post, that's not a word. You're thinking of the word "subjective".

    2. Re:Definition of Scalable by Morgahastu · · Score: 1

      Oops.

    3. Re:Definition of Scalable by Anonymous Coward · · Score: 0
      This is just me being a grammar nazi, but you use the word "subjectable" in the first sentence of your post, that's not a word.

      Actually, subjectable is a word. It means "capable of being subjected to," as in "your solution is subjectable to analysis."

      Just FYI! :)

    4. Re:Definition of Scalable by Tony-A · · Score: 1

      All that matters is that it will work with higher demand. Who cares how or why.

      Completely correct until you have to figure out whether or not it is scalable, for your required definition of scalable.

      "subjectable" [can be made subject to ...] methinks is the correct word, whether or not anyone else has previously used it. "subjective" would also work but gives a much weaker meaning to the sentence. You can make the term "scalable" mean what you want/need it to mean. I can ditto independently.

      I think in general it means that within the expected range of increased load, the costs, etc are essentially linear. Traffic jams are a ubiquitous example of non-scaleable traffic systems. You reach a point where changes in results are all out of proportion to changes in inputs.

    5. Re:Definition of Scalable by smagruder · · Score: 1

      Here is a suitable definition for ya.

      --
      Steve Magruder, Metro Foodist
  10. scalability is a dead issue by jenkin+sear · · Score: 5, Insightful

    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.

    --
    What a strange bird is the pelican, his beak can hold more than his belly can.
    1. Re:scalability is a dead issue by Anonymous Coward · · Score: 3, Insightful

      you are correct that you are incorrect.... if anything, developers are moving towards MVC, like Mojavi - 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.

    2. Re:scalability is a dead issue by julesh · · Score: 4, Interesting

      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 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.

    3. Re:scalability is a dead issue by Anonymous Coward · · Score: 1, Interesting

      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.

    4. Re:scalability is a dead issue by iamdrscience · · Score: 1

      Any developer tackling a serious project will soon realize the same "problems" with maintainability you have, but fortunately, there are solutions to all of them. First and foremost, is the Smarty templating engine. Then there are the PEAR classes, PECL extensions and if you want to get all CS-ey, there are the OO features of PHP which are expanded and refined in PHP5 (and unlike Perl 6, PHP5 will actually be the release version in the very near future).

      If PHP were as unmaintainable as it seems to all of you people that are unfamiliar with it then people wouldn't use it, but thousands of professional websites (Yahoo, Friendster, etc.) DO use it, and that alone speaks volumes about how competitive it is with Java, Perl, Python, etc.

    5. Re:scalability is a dead issue by julesh · · Score: 2, Informative

      My main issue with PHP scalability is the lack of a global context for app-level caching.

      http://www.php.net/manual/en/ref.sem.php -- system V shared memory. See specifically the functions shm_put_var() and shm_get_var().

    6. Re:scalability is a dead issue by dekeji · · Score: 1

      My big issue with PHP is maintainability-

      True: a lot of big PHP packages look awful and can't be touched without falling apart.

      Sadly, the same is true of a lot of big software packages written in other languages.

      The solution? Hire better programmers or keep your software small and simple. In fact, the former will likely result in the latter.

      blow off any MVC separation

      I think it's an article of faith, not fact, that MVC contributes anything to maintainability.

    7. Re:scalability is a dead issue by Anonymous Coward · · Score: 0

      and unlike Perl 6, PHP5 will actually be the release version in the very near future

      Of course unlike Perl 5, PHP 4 is a bloated sack of shit, something PHP 5 doesn't endeavor to change.

    8. Re:scalability is a dead issue by Anonymous Coward · · Score: 0

      Scaling horizontally isn't a panacaea. You'll eventually run up into Amdahl's law, where adding any number of machines isn't going to save your application unless it's massively parallel, and those applications turn out to be rather few and hard to design and program.

    9. Re:scalability is a dead issue by shut_up_man · · Score: 2, Interesting

      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.

  11. Who know what scales? by Lolaine · · Score: 3, Interesting

    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.

    --
    ------- The last Sig. got fired.
    1. Re:Who know what scales? by julesh · · Score: 1, Redundant

      pentium support was removed?

      I'm currently running PHP 4.2, a recent Apache 1.3 and Linux 2.4 on a Pentium 100MMX without difficulty.

    2. Re:Who know what scales? by julesh · · Score: 1

      Ignore me. I misread the GP post.

    3. Re:Who know what scales? by badriram · · Score: 1

      Maybe you should read a bit more about the mono project and ASP.NET. Because right now, I am running a bunch of ASP.NET/Apache2/UNIX.
      There is also SunOne ASP which would let you run ASP on Apache/UNIX based systems.

    4. Re:Who know what scales? by Anonymous Coward · · Score: 0

      I agree, why do people insist on thinking they can make their 486 perform like a P5? Scalability in reference to speed isnt even a metric (something some reporter made up to sound credible?), yes java will run faster on a 1.5Ghz PC as opposed to a 300Mhz but after 800Mhz the speed of java becomes a non-issue. If you are creating a "real" website instead of a personal hobby website you are not going to go and buy an old cheapo PC to run it on, you are going to go and buy the equipment that gives you the ability to give your customer what they are demanding.

  12. Maintaining State by goul · · Score: 1

    From the article
    "Scalability is gained by using a shared-nothing architecture where you can scale horizontally infinitely. A typical Java application will make use of the fact that it is running under a JVM in which you can store session and state data very easily and you can effectively write a web application very much the same way you would write a desktop application. This is very convenient, but it doesn't scale. "

    Storing and more importantly trying to replicate stored state via sessions in Java can be expensive, but saying Java scales badly because it makes it easy to do things that don't scale well is a poor argument. I don't know enough about the merits of PHP to comment on how it deals with this issue, but when you've done lots of server side Java programming you learn to be very judicious in the use of Session scope.

    1. Re:Maintaining State by julesh · · Score: 1

      In fact, PHP sessions work in almost exactly the same way as a Java servlet session; they store variables in a memory block that is shared between all the PHP processes (as opposed to one that is shared between threads for Java). You can use disk or a database for storage, if you want, but exactly the same options ought to be achievable with Java, surely?

    2. Re:Maintaining State by the+eric+conspiracy · · Score: 1

      they store variables in a memory block that is shared between all the PHP processes

      The problem with PHP in this area is that it doesn't have the flexibility Java does in scoping serverside objects. Java has page, request, session and application scopes. PHP's limitations make it difficult to implement MVC frameworks that are as powerful as say, Apache Struts.

    3. Re:Maintaining State by selkirk · · Score: 3, Informative
      PHP sessions are NOT stored in a memory block shared between PHP processes. The default is to store session information in a file on disk. This is the point of the debate. "Shared nothing" means that there are no memory blocks shared between PHP processes.

      As your application scales beyond one server, you then need to find a way to share your session between servers. This can be done in PHP via NFS with the default file based session driver (I think sourceforge does this), or with a database session driver.

      If you had stored sessions in memory, then you would encounter problems with having to route requests based on session, or migrate to a method for sharing session data between machines.

    4. Re:Maintaining State by iamacat · · Score: 1

      Storing and more importantly trying to replicate stored state via sessions in Java can be expensive

      And why would you want to do such a thing? Just tie each session to a home server and redirect the user to s155.mysite.com when he/she logs in. For some tasks it's better to keep state in memory, for some database is the correct solution. I don't see how using a language with only one option is an advantage.

    5. Re:Maintaining State by goul · · Score: 1

      And why would you want to do such a thing?

      For failover if you loose a node in the cluster.

      Application servers like Resin support the synchronisation of these in memory sessions with failover when a node dies/is taken out of service etc.

  13. Not always a good thing... by Dozix007 · · Score: 2, Insightful

    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 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.

    1. Re:Not always a good thing... by aled · · Score: 1, Troll

      Quick and dirty; PHP is the VB of XXI century ;-)

      --

      "I think this line is mostly filler"
    2. Re:Not always a good thing... by zangdesign · · Score: 4, Insightful

      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.

      --
      To celebrate the occasion of my 1000th post, I will post no more forever on Slashdot. Goodbye.
    3. Re:Not always a good thing... by Dogtanian · · Score: 1

      I hate to say it, but the problem exists between keyboard and chair. PHP is not inherently secure or insecure language.

      Well, unless I misparsed the grandparent correctly, it didn't imply that at all; it said "It is not a good thing that there is a short learning curve on PHP"- implication, the ease of use is the problem, as opposed to "PHP is insecure".

      --
      "Slashdot - News and Chat Sites Deviant". (Click "homepage" link above for details).
    4. Re:Not always a good thing... by zangdesign · · Score: 1

      Read the sentence after it in which he blames the language for insecure sites, rather than the developers.

      --
      To celebrate the occasion of my 1000th post, I will post no more forever on Slashdot. Goodbye.
    5. Re:Not always a good thing... by Dogtanian · · Score: 1

      Read the sentence after it in which he blames the language for insecure sites, rather than the developers.

      The phrasing could be better, but if he/she meant to imply that PHP had shitty security, I reckon it would have been more explicit.

      --
      "Slashdot - News and Chat Sites Deviant". (Click "homepage" link above for details).
  14. Yahoo. by downbad · · Score: 5, Interesting
    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.

    1. Re:Yahoo. by Anonymous Coward · · Score: 5, Informative
      Actually that's only partially true. Yahoo uses C/C++ for almost all backend development. PHP is used mostly for what it's good at: Simple web frontends that call on extensions written in C and C++ to do most of the heavy lifting, or access backend systems written in C/C++.

      Yahoo is very much a C/C++ shop first and foremost - PHP is used as a template system (alongside several proprietary systems) to allow easy modification of high level behaviour.

    2. Re:Yahoo. by Anonymous Coward · · Score: 1, Informative

      That's only partially true as well -- Yahoo uses Perl for tons of their backend stuff. But yes, PHP is only the finally delivery bit, not the actual applications at Yahoo.

    3. Re:Yahoo. by Anonymous Coward · · Score: 0

      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.

      I think this illustrates nicely what being a PHP pro is like - being able to handle objects and stuff. :)

      I think one of the reasons PHP has become so succesful is because it doesn't separate code and data, which means that people who usually wouldn't develop CGI scripts in C can easily insert code into their markup. And trust me, as much as there are a lot of cool, efficient PHP coders (I know a few, they are efficient), there are even more who consider themselves able to create Web portals by changing the copyright message in you flavour of the *Nuke CMSes that occasionally are victims of an SQL injection bug.

      Who are benefitting from this? I am not.

    4. Re:Yahoo. by PizzaFace · · Score: 1

      For an inside look at why and how Yahoo uses PHP, see Michael Radwin's talks.

    5. Re:Yahoo. by moro_666 · · Score: 1

      i guess you people are mostly missing the global issue here that php itself doesn't really scale anywhere.

      apache and it's php executing module are the ones that scale.

      php is just a scripting language like any other, the fact that it's really easy to learn may make it "the choice" for some people.

      as long as php isn't running on it's own virtual machine separatly with real php threads and shared variables, i see no scaling in php whatsoever.

      still comparing java with php is somewhat a nonsense cause these langauges are used in completely different levels and there is no point whatsoever to write a small website in java and there would be a huge mess in some serious systems (hospitals, insurances and so on) if there weren't ejb's and real application servers involved.

      try not to put it "java vs php", to make the best of it make them work together, this way you will have the scalability that java has with appservers and the j2ee business around it, and at the same time a nice easy to write and understand scripting language which enables you to write easy and simple code really fast.

      bot languages have very many advantages and disadvantages, but if you are comparing them , then java is a railroad train, it can handle enormous loads and do things that php as hot racing car just can't do, but at the same time, php can make really quick turns which a train never can do.

      java is a complete platform which nowadays runs almost everywhere. php is a scripting language which's code can be executed by webserver or the php4 executable, and it sure doesn't run everywhere.

      before you reply on this message with "ha php is so much better" , i'd suggest you get a real expert on both languages, use a lot of multithreading (well php doesn't do that but java does). also try to write code which uses interfaces do abstract things, dynamical class loading, over the net classloading and try to make as much use of JIT as you can. try to generate bytecode for your app to use in runtime so you could modify and load it as a class whenever you want to. also try to run the code that you wrote 3 years ago on the platform now. all the java stuff still works, very much of the php code is broken (cause some smartasses at zend can't decide what to do ? come on people, the are basically ruining the simplest language ever written)

      i wish you all the best and may choice of programming language be directed by your application needs and not by your blind love for one language.

      --

      I'd tell you the chances of this story being a dupe, but you wouldn't like it.
    6. Re:Yahoo. by danharan · · Score: 1

      Most informative! The one-year after talk has some excellent info. It's quite a surprise that Y! doesn't have a clean MVC separation, and that Radwin feels the need for something akin to Struts in PHP.

      Now, if we could have easily use PHP instead of JSP, I could keep coding in JAVA (instead of C), and you could have junior programmers or heck, even some designers using PHP on the page... that could be the easiest solution.

      --
      Information: "I want to be anthropomorphized"
    7. Re:Yahoo. by aled · · Score: 1

      How hard would be a PHP in Java? The language doesn't seems so complicated.

      --

      "I think this line is mostly filler"
    8. Re:Yahoo. by AmVidia+HQ · · Score: 2, Interesting

      Ahem. You copied my comment I wrote some time ago. When you copy, give credit where it's due.

      --
      VIVA1023.com | Political Fashion.
    9. Re:Yahoo. by downbad · · Score: 1

      You, sir, are correct.

  15. Scalability and Maintainability go hand in hand by Christianfreak · · Score: 4, Insightful

    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.

    1. Re:Scalability and Maintainability go hand in hand by julesh · · Score: 1

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

      Namespaces are handly, I'll agree, but I don't see them as a golden-bullet that are impossible to live without.

      Let's face it, they don't actually achieve anything that a consistent naming strategy couldn't also achieve.

    2. Re:Scalability and Maintainability go hand in hand by iamdrscience · · Score: 4, Informative

      You sound like somebody who didn't use PHP long enough. Large PHP projects become plenty maintainable once you start using handy stuff like the Smarty templating engine (which IIRC is included by default now). There are also a myriad of great PEAR classes and PECL extensions. As for a module architechture that doesn't require you to recompile, that would be nice, however, I would bet that most PHP programmers have never recompiled their installation or needed to do so. You're right though, it would be nice.

      For the most part though, I would say that PHP is slightly better equipped for web development, just like Perl is better equipped for general scripting tasks... I'm a python man myself though ;-)

    3. Re:Scalability and Maintainability go hand in hand by mrandre · · Score: 5, Insightful

      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.

      --
      "I don't want to achieve immortality through my work. I want to do it by not dying." -Woody Allen
    4. Re:Scalability and Maintainability go hand in hand by sweede · · Score: 1

      PHP has a module arch, if you need new functionality you compile that extension and load it in the php.ini or your script using dl().
      Templates? use Smarty templates. www.php.net uses them and as said elsewhere, they're included in the php pear package.

      If you are talking about basic/core php functionality, then what do you expect? maybe you should post to the kernel mailing list asking that all the new features/enhancements of the kernel be in a module so you dont need to recompile the kernel.

      --
      I follow the SDK and GDN principles.. Spelling Dont Kount, Grammer Dont Neither
    5. Re:Scalability and Maintainability go hand in hand by Camel+Pilot · · Score: 1

      Perl can become unmaintainable on a small project

      What unique attributes of perl do you believe contribute to your claim that perl "can become unmaintainable on a small project"?

      I regularly program in C and I would say that C has numerous issues that make readability and maintainability in the large but you rarely see anyone heap this scorn on C.

    6. Re:Scalability and Maintainability go hand in hand by Doctor+Crumb · · Score: 1
      PHP only becomes unmaintainable if you don't know what you're doing, or if you don't plan well at the onset.

      In the Real World, you rarely get to write the web app yourself; instead, you get to add features/clean up/fix the web app that the Other Guy wrote. The Other Guy invariably doesn't know what he's doing, nor did he plan well at the beginning. Knowing this is the case, I would much rather he were using an environment that forces some amount of good design on him, since that will save me time and frustration. Being allowed to write bad code is great for learning a language, but horrible for actual development.

      I like most of perl. I like parts of PHP. I love HTML::Mason, I love PEAR classes. Scalability and maintainability come from using existing extensions to do the heavy lifting instead of rewriting the wheel every time, a lesson that most web programmers have yet to learn. Discipline is still required, but if your environment lets you immediately get down to making the thing work, you won't be as tempted to toss in ugly hacks.

    7. Re:Scalability and Maintainability go hand in hand by Anthony+Boyd · · Score: 1, Funny
      What unique attributes of perl do you believe contribute to your claim that perl "can become unmaintainable on a small project"?

      I bet he heard that from good old Tim Towtdi!

      ;)

    8. Re:Scalability and Maintainability go hand in hand by ExileOnHoth · · Score: 1

      I manage a large, complex "digital asset distribution system" (marketingspeak for permissions-controlled data, content and downloadable files) for a well known entertainment company. All php, and it's incredibly maintainable.

      That's because we try to be smart about our application design. Separate tiers for data, logic, presentation. Object oriented programming in PHP has come a long way. If you don't know anything about it, perhaps you should give it a shot.

      Php has grown: the tools are there to do smart design.

      It all depends on good programmers in the end. Just like everything else.

    9. Re:Scalability and Maintainability go hand in hand by Anonymous Coward · · Score: 0

      Exactly! I like typing function names like gnufowl_featherlib_chicken_pluck(). It's so descriptive! RSI be damned!

    10. Re:Scalability and Maintainability go hand in hand by Desert+Raven · · Score: 1

      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'


      Hmm, maybe you've heard about classes?

      All of my recent PHP projects have had 90% of their code in various classes, with the rest just gluing them together and calling the class functions. Very simple to maintain, and it solves the whole namespace issue very nicely.

      It's just a language, it's how you use it that matters.

    11. Re:Scalability and Maintainability go hand in hand by IpSo_ · · Score: 2, Informative

      "a module architechture that doesn't require you to recompile"

      Your kidding right?

      urpmi php-mysql php-pgsql php-curl php-xml php-sockets
      service httpd restart

      See any "make; make install" commands in there?

      How is that not modular?

      Nearly everything in PHP is a module (or PHP's term, an extension) that can be installed or removed without recompiling.

      --
      Open Source Time and Attendance, Job Costing a
    12. Re:Scalability and Maintainability go hand in hand by Anonymous Coward · · Score: 0

      What about the GD library extension, TTF, Type1 fonts, etc. that can only be utilized by recompiling? Take a look, there are plenty of popular functions that you can only use by recompiling PHP.

    13. Re:Scalability and Maintainability go hand in hand by Anonymous Coward · · Score: 0

      Why use Smarty when PHP is a template engine *already*?

      I sure hope it isn't included by default with PHP.......

    14. Re:Scalability and Maintainability go hand in hand by Tony-A · · Score: 1

      What unique attributes of perl do you believe contribute to your claim that perl "can become unmaintainable on a small project"?

      Hardly unique, but it uses letters and numbers and some special characters for identifiers and other stuff. The way these are/can be used allows perl (or any other language) to become unmaintainable on a small project. With adequate care of assinging identifiers it would be possible to maintain very large projects using old FORTRAN 6-character name space. I'm sure it would also be possible to build large, complicated, dynamic systems in COBOL.

    15. Re:Scalability and Maintainability go hand in hand by Camel+Pilot · · Score: 1

      but it uses letters and numbers and some special characters for identifiers and other stuff.

      Yes $ @ and % are used to distinguish the three data types in perl. Is that a disadvantage or advantage? I do prefer this method over some contrived data naming scheme like hungarian notation. I think this enhance readability.

      As far as the use of numbers in identifiers the only use I know of is the $1,$2,etc in the last regexp match. Again I do not see that as a confusing or maintenance issue just a protocol.

    16. Re:Scalability and Maintainability go hand in hand by Tony-A · · Score: 1

      numbers in identifiers -- the obvious I1 I2 J1 J2 A3PJ7Q

      $ @ % to distinguish data types -- particularly if they occupy different name-spaces. Much cleaner if $foo @foo %foo co-exist and are handled differently.

      contrived data naming scheme -- Mathematics and Engineering tend to love single-character names. They've been in the business for a long time. I suspect they know something about keeping your head straight when facing complexity. It helps immensely when something that is different looks different.

      If the project is small enough, anything that distinguishes "this" from "that" will do nicely. When the project is large, something systematic must be done so that someone who has never seen the code or the variables before knows exactly what they represent. I suspect that something like hungarian notation manages to be exact on what doesn't matter at the expense of sloppiness on what does matter ;-)

    17. Re:Scalability and Maintainability go hand in hand by Christianfreak · · Score: 1

      Actually, coding PHP is part of my job. I do both it and Perl.

      I've used PHP for two years now and in several large projects. I tried Smarty, didn't like but I am glad its included by default since it is better than embedding into HTML, especially when working with designers that don't know and won't learn the tinyiest scrap of code. For templating I use PHP-HTML Template, which is compatable with HTML::Template in Perl (which is convient since we use both).

      Unfortunatly PEAR doesn't come close to CPAN, the only thing I use from it are the DB modules. Many modules I've tried didn't work, documentation is almost nil and there are tons of things missing. Such as an HTML Parser.

      My point is, its quite the opposite. The more I work with PHP the more I find it lacking. I think even adding some of the needed things to make the language better are too little too late. Even if it all gets in you have an army of "programmers" that aren't going to stop embedding code into HTML, aren't going to stop requesting functions be added to the core that have no business being there.

    18. Re:Scalability and Maintainability go hand in hand by Christianfreak · · Score: 1

      Any language can become unmaintainable if you don't follow good practice. (Including Perl) and while learning I wrote lots of bad Perl code as well.

      The problem is that PHP encourages bad practices (IE embedding code into HTML) and doesn't support some very basic things that are in other languages that make maintaiability easier such as namespaces or common naming convention for at least core functions!

    19. Re:Scalability and Maintainability go hand in hand by swillden · · Score: 1

      PHP only becomes unmaintainable if you don't know what you're doing, or if you don't plan well at the onset.

      I started developing a small to medium-sized PHP application about a year ago (it's up to about 12,000 lines). It was my first PHP project, although I'm an experienced software developer (professional for ~15 yrs, mostly C++ and Java). I immediately realized that PHP is a kitchen-sink sort of language, and one which requires a lot of discipline to keep projects under control. That's fine, I like languages that give me lots of options, and I understand how to write disciplined code.

      The problem was, that it was not at all clear how PHP should be written. There are many ways to accomplish any given task, and while it's sometimes obvious that some ways are bad, often it's not clear at all until you've done it the wrong way a couple of times and been bitten by your error. So, I did the smart thing: I looked for advice from serious, experienced PHP developers, who had made the mistakes, devised solutions and worked out the best approaches and techniques.

      The problem was, I didn't find any such advice. I found lots of little articles on how to solve this particular problem or that, and much of that was helpful (although much of it was clearly written by people who weren't much beyond novices with either PHP or programming in general, and who were either solving trivial problems or solving their problems in ways that were obviously poor). I found nothing on how to structure complex systems, what approaches to use (or avoid) to increase maintainability, what issues to consider with respect to scalability (of code base, team size and user base).

      Is such information available? If so, where? At this point I've learned enough that I'd like to scrap my existing system and start over, because I know much more about how to write PHP than I did. But even if I were foolish enough to do such a thing, I have no doubt that I'd just end up with another system I want to rewrite, because I'm sure I still have a great deal to learn about PHP.

      --
      Note to ACs: I usually delete AC replies without reading them. If you want to talk to me, log in.
    20. Re:Scalability and Maintainability go hand in hand by adamfranco · · Score: 1

      During the developement of our PHP CMS, Segue, we did just what you mentioned: a rewrite, with the realization that another was needed before the first was even done. To nip this one in the bud, we spent several months researching application design, OO design, XP, and several other topics. This research left us with two products:

      - A large application framework (Harmoni) written in PHP that provides implementations of the Open Knowledge Inititiative (OKI) services along with others.

      - A site that is a collection of most of the articles that we read in preparation to all this work.

      The documentation site title is XP, but the articles contained are more general design stuff than just XP. Speaking of XP, it is something that over time we have found to be partially useful. Unit testing can be good, though we often don't do it, while pair-programming is universally despised by our group.

      Anyway, read a lot before writing.

      --
      "When ideology and theology couple, their offspring are not always bad but they are always blind." -- Bill Moyers
    21. Re:Scalability and Maintainability go hand in hand by swillden · · Score: 1

      Anyway, read a lot before writing.

      Always. Finding good information about PHP to read has been the problem.

      Thanks for the pointers, I'll look into them.

      --
      Note to ACs: I usually delete AC replies without reading them. If you want to talk to me, log in.
  16. Friendster's No-Hacking Policy by Anonymous Coward · · Score: 0

    I'd like to point out this blog post on Kottke:

    Moore's buddy Matt Chisholm chimes in to tell me about a similar hack, a JavaScript app he wrote with Moore that works on Friendster. It mines for information about anyone who looks at his profile and clicks through to his Web site. "I get their user ID, email address, age, plus their full name. Neither their full name nor their email is ever supposed to be revealed," he says.

    Notified of the security holes Moore and Chisholm exploit, Friendster rep Lisa Kopp insists, "We have a policy that we are not being hacked." When I explain that, policy or no, they are being hacked, she says, "Security isn't a priority for us. We're mostly focused on making the site go faster."

  17. Agree on defination first by bangular · · Score: 4, Interesting

    The term "scalable" has become an industry buzzword. It is fruitless to argue whether something is scalable or not if there is no clear defination. It's like arguing whether you believe in freedom or not. Of course most people in the world will say they believe in freedom, but if you ask 100 people to define it you will get 100 different answers (the Bush administration has had a field day with this because the minute you oppose them, they accuse you of not believing in freedom; their defination of course).

    It is impossible to say php is or is not scalable unless a defination can be agreed on. And with "scalable's" current buzzword status, I don't see that happening very soon.

    1. Re:Agree on defination first by Anonymous Coward · · Score: 0

      Definition. You bloody idiot.

    2. Re:Agree on defination first by yow2000 · · Score: 1

      Agree on spelling second?

    3. Re:Agree on defination first by Anonymous Coward · · Score: 0
      the Bush administration has had a field day with this because the minute you oppose them, they accuse you of not believing in freedom; their defination of course

      And that's when you remind everybody that the NAZIs has a similar definition of freedom.
  18. Implementing a site in PHP... by bigattichouse · · Score: 3, Insightful

    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.

    --
    meh
    1. Re:Implementing a site in PHP... by C_Kode · · Score: 2, Informative

      I don't think it's inefficient. I use it. I have an extensive CLI PHP scripting system setup that does it all. It connects to FTP systems downloaded data for updates, runs updates on several databases, generates plain text reports, csv (Excel type reports), and most of all combining it with crontabed called from others systems it allows me to share data between two systems that previously where unable to do so.

      This also allows me to move code blocks between different platforms without issue. It also allows some of our beginning programmers to make changes and updates to this systems without having to know 5+ different languages. Most of them took C classes in school and the transition to PHP is fairly easy. We have a online documentation server (php/postgresql) that we also keep a list of no nos for programming in php so alot of those new to php don't make common mistakes. I have found php to be invaluable. Sure it's doesn't fit for every job in you come up with, but it makes system automation a snap.

      Anyway, it's made my job much easier. Perl can do everything that CLI PHP can, but it's far less cryptic to those that are new to it which means far less training time and far less debugging on my part after someone new to the language drops syntactic money wrenches into our code or logical errors.

    2. Re:Implementing a site in PHP... by takshaka · · Score: 1

      Perl can do everything that CLI PHP can, but it's far less cryptic to those that are new to it which means far less training time and far less debugging on my part after someone new to the language drops syntactic money wrenches into our code or logical errors.

      I agree. Perl is far less cryptic.

      By the way, you seem to have dropped a syntactic monkey wrench or two into your logical errors.

    3. Re:Implementing a site in PHP... by imroy · · Score: 1

      *yawn* Perl.
      :)

    4. Re:Implementing a site in PHP... by Tony-A · · Score: 1

      Sound inefficient, sure, but it works like a champ

      Efficiency is always a matter of never being too inneficient for the context. Basically, you have a certain amount of time in which to do whatever it is you need to do. Faster isn't really any better, but slower always hurts.

    5. Re:Implementing a site in PHP... by smagruder · · Score: 1

      Based on the story he provides, he meant "PHP is less cryptic" but made it appear he was referring to Perl due to some unfortunate grammar. And I agree that PHP is less cryptic, hands down.

      --
      Steve Magruder, Metro Foodist
    6. Re:Implementing a site in PHP... by Anonymous Coward · · Score: 0

      Hi. Humor Patrol here. Something seems to have flown over your head. Let's review:

      C_Kode: Perl can do everything that CLI PHP can, but it's far less cryptic

      takshaka: I agree. Perl is far less cryptic.

      In context, C_Kode obviously means that PHP is less cryptic. takshaka apparently misunderstood, though.

      C_Kode: which means far less training time and far less debugging on my part after someone new to the language drops syntactic money wrenches into our code or logical errors.

      takshaka: you seem to have dropped a syntactic monkey wrench or two into your logical errors.

      Aha. The parallelism here seems to be pointing out the poor grammar of the original statement, indicating that takshaka had no problem discerning its meaning. His misunderstanding must have been deliberate, an example of ironic humor.

      smagruder: he meant "PHP is less cryptic" but made it appear he was referring to Perl due to some unfortunate grammar. And I agree that PHP is less cryptic, hands down.

      As we can now clearly see, smagruder is a dour, humorless PHP programmer.

    7. Re:Implementing a site in PHP... by smagruder · · Score: 1
      As we can now clearly see, smagruder is a dour, humorless PHP programmer.

      Plenty of humor in my heart. I just wanted to ensure that other readers weren't lost on takshaka's point. Further, methinks those who attack others from the shadows have far worse issues than "dour, humorless programmers".

      --
      Steve Magruder, Metro Foodist
  19. The reason by Diclophis · · Score: 2, Insightful

    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).

    1. Re:The reason by earache · · Score: 1

      Everything you mentioned is a horrible example of "truly N-Tier design". SOAP, CORBA are too heavy for any kind of complex interaction, and XML-RPC still requires HTTP to function, which means yet another webserver to set up and maintain.

      I'm a .NET douche bag, and most of the projects I work on are deployed on server farms, so scalability is something I know a little about. Obviously, with .NET, it's a bit of a no brainer to get working since it's an intrinsic design to the framework.

      We use the pattern of localized cache, with one server acting as a cache manager. If an object graph on one server changes, it notifies the cache manager which notifies every other server to refresh. Doing this, we limit DB interaction from the middle tier to insert and updates, grabbing data from the DB only occurring once and cached on each individual app server until something changes and it's refreshed. Obviously, this isn't cool for data that is mission critical and must always be up to date, so in those instances we pull directly from the DB to avoid synchronization issues with the cache manager. But it's pretty rare we find a dataset that has to be handled that way.

      I don't see how PHP could accomplish anything like that since it doesn't have state and is techinically more of a pre-processor than it is an application server.

  20. in a nutshell: by Anonymous Coward · · Score: 0

    Java: Wack
    PHP: Dope

  21. rebuttal by Anonymous Coward · · Score: 4, Informative

    I will start with mandatory links to the great series of articles that Ace's Hardware ran, describing their server scenario and their migration from PHP to Java/J2EE:

    1. Building a Better Webserver
    2. Building a Better Webserver in the 21st Century
    3. Scaling Server Performance

    The PHP Scalability Myth starts of by defining three types of server architectures. The first, two-tier, and the last, logical-three-tier, are the same conceptually (there is the slight distinction between whether display and business logic code is "mingled", but this is typically not a performance issue, but just an aesthetic or design issue). This two-tier/logical-three-tier architecture is the only one PHP supports natively. The article then proceeds to compare a two-tier PHP architecture against the most elaborate full three-tier Java architecture, which is used rarely in practice, and extremely rarely in the same domain in which a PHP solution is feasible. Instead of comparing apples and oranges (if PHP supported a full three-tier architecture, I would imagine two-tier PHP vs. three-tier PHP would have the same performance discrepencies), let's simply compare the only architecture PHP supports natively, two-tier, against JSP talking directly to a database, as this scenario is the most analogous to the PHP one. Let's also discard any caching as again this is something that Java handily accomodates but is not natively (or at least easily) available in PHP due to lack of state. And let's assume the database is the largest bottleneck.

    The article states:

    At the time when the first versions of the JSP and EJB standards were released, the prevalent web server was (and still is) Apache 1.x, which had a process model that was not compatible with Java's threading model. This meant that a small stub was required on the web server side to communicate with the servlet engine. The remains a non-trivial performance overhead for those that decide to pay it, and was a significant performance overhead when the first scalability comparisons were made.

    I'm not sure what "stub" the article is referring to, but I will assume it means an Apache module which talks a "native" protocol to the servlet engine. The first such module was mod_jserv, which could run the servlet engine both in-process and over a compact protocol called AJP (Apache Java Protocol), which represents essentially a pre-parsed HTTP requests. This module, as well as the AJP protocol itself has gone through severel revisions, from mod_jk, to mod_jk2. I cannot quite recall, but I think some version of mod_jk might have lost the ability to run in-process. Every other version, including the most current, can, if I recall correctly. This is besides the point, because as far as I know, AJP always has been a trivial performance overhead (I believe recent versions can run over Unix domain sockets). In fact, Apache is routinely used in production as the front-end web server, instead of the built-in servlet engine web server, simply because it is faster at serving static content, and that the AJP protocol is negligable. If the "stub" referred to in the quote is not the AJP module, then this may not be relevant, nevertheless AJP has always been highly efficient and typically negligable with regard to performance (the same typical connection min/max/idle count configurations apply as do to Apache itself).

    The article goes on to proclaim the complexities of caching and data object persistence which we have eliminated from our comparision. Let's move on to the real bottleneck - the database. The article says "PHP's connectivity to the database consists of either a thin layer on top of the C data access functions, or a database abstraction layer called PEAR::DB. There is nothing to suggest tha

    1. Re:rebuttal by julesh · · Score: 4, Informative

      This two-tier/logical-three-tier architecture is the only one PHP supports natively.

      I'm not sure what you're on, but you can build however-many-tiers-you-like applications with PHP. In fact, PHP supports a number of technologies specificallly designed to communicate with additional tiers, including CORBA, JavaBeans and SOAP.

      Let's also discard any caching as again this is something that Java handily accomodates but is not natively (or at least easily) available in PHP due to lack of state

      PHP supports persistent state through shared memory blocks trivially. The implementation of data caching schemes that use this feature is not hard.

      17 child threads attempt to connect, one will not be able to. If there are bugs in your scripts which do not allow the connections to shut down (such as infinite loops), a database with only 32 connections may be rapidly swamped

      Why would you limit your database to serving fewer connections than you have limited your web server to?

      PHP supports an option to kill runaway scripts and reclaim their resources after a time limit has elapsed, which handily prevents the infinite loop problems mentioned.

      Ok, so now we have a bunch of "persistent" connections that hang around with the process. How long do they hang around?

      Until the database closes them or the PHP server process is killed.

      What if two threads in the same process want to use a connection?

      The connection is locked from the moment a thread acquires it (using the *_pconnect function) until the script using it terminates.

      In the worst case, persistent connections make your problem much much worse, because now you have many more connections open to your database.

      What does an inactive open connection to the database cost? Not very much, in my experience.

      Your arguments have a little merit, but please try to do your research before ranting about a system.

    2. Re:rebuttal by Anonymous Coward · · Score: 0

      damn you haveto much time on your hands....

    3. Re:rebuttal by kashani · · Score: 1

      I don't agree with much the original poster of this thread said, but having many persistent connections to your db can be an issue. Mysql tends to get extremely unhappy at the 1000+ connections range. That's on a Dell 2650, dual PIII, 4GB ram machine, ymmv.

      kashani

      --
      - Why is the ninja... so deadly?
    4. Re:rebuttal by Desert+Raven · · Score: 1

      ...having many persistent connections to your db can be an issue. Mysql tends to get extremely unhappy at the 1000+ connections range.

      Mysql is not the only one. Each DB connection takes up system resources and database resources. A few years ago, I saw an Oracle database brought to its knees when our website got hit hard, causing well over 2,000 simultaneous database connections. It wasn't the main Oracle process that was the problem, it was the resources that all the listeners were consuming. Re-allocating more resources to the listeners solved the issue, but that takes resources away from the main DB engine. The Oracle server in question was a dual-processor E450 with 2GB RAM.

      I love PHP, I use it almost exclusively for web apps. But I have serious misgivings about its scalability due to a lack of managed database connection pooling.

    5. Re:rebuttal by Ogerman · · Score: 1

      PHP supports persistent state through shared memory blocks trivially.

      You refer to the Unix-specific shmop extension. I don't think that 'trivial' is the right word, considering that developers are left to pretty much come up with their own memory management routines unless their needs are also trivial. Serializing objects all the time is hardly efficient either.

      The implementation of data caching schemes that use this feature is not hard.

      Are there any existing frameworks? For supposedly being so easy, there sure aren't many people doing it.

    6. Re:rebuttal by kashani · · Score: 1

      Nice job explaining the resources per connection stuff.

      There are some interesting ways to connection pool with PHP, but they require you to jump through some hoops. I do wish they'd get proper pooling though.

      1. apache2, threading, php. Still pretty beta if you need to support anything other than the basics. Apache handles the threading and you have less db connections. At least that's how I understand it.

      2. proxypass to a php enable Apache. Run mutiple instances of Apache and pass php requests to a dedicated Apache. Let your frontend Apache do the serving the backend do the db connections.

      Haven't tested either fo thise and they reuqire to do some planning or accept a much lower subset of the usual functionality.

      kashani

      --
      - Why is the ninja... so deadly?
  22. Let's find out. by CordMeyer · · Score: 1

    What is the largest, or most heavily used php driven site?

    1. Re:Let's find out. by freezin+fat+guy · · Score: 1

      The busiest website in the world. As was already mentioned, Yahoo! runs on PHP. I would also hazard a guess that their code does not look quite like the kind of quick and dirty scripts most of us are guilty of firing off for cheap low-to-moderate load applications.

      Regardless of platform, application design is just about the most critical factor in ensuring high load performance. If you want your PHP driven site to scale well to heavy loads you will wind up using a few concepts more familiar to the J2EE crowd.

    2. Re:Let's find out. by selkirk · · Score: 2, Informative
      The answer is Yahoo. Here are a couple of talks on the issue:

      One year of PHP at Yahoo
      Making the case for PHP at Yahoo

    3. Re:Let's find out. by CordMeyer · · Score: 1

      Thanks for the links.

  23. Line 8000 - wtf by panurge · · Score: 1
    No-one seems to have picked this up, but it says it all. If any of your support classes has a Line 8000, especially one at which an exception can arise that is not being caught, you may need to go back and do a few basic classes in software design.

    Confession time: the worst Swing based class I have ever committed has about 4000 lines, but about 2/3 of that is Swing.

    --
    Panurge has posted for the last time. Thanks for the positive moderations.
  24. Real world examples? by javab0y · · Score: 4, Interesting

    I think to settle this debate is a possible real-world example. Look at the story on the Jboss Nukes Project. 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.

    1. Re:Real world examples? by Anonymous Coward · · Score: 2, Interesting

      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!

    2. Re:Real world examples? by javab0y · · Score: 1

      No...your comparison is "apples to oranges" and has no basis. MS did not compare it properly. They used stored procedures, etc, where the J2EE was an exercise of keeping the business logic in the beans and not in the database. The java blueprints were never meant to be an exercise of performance over different design pattern examples. See the real low down on the MS Petstore implementation. Its just another example of the FUD that is sold by M$.

  25. What's the deal with nutshells? by Anonymous Coward · · Score: 0

    Are they dope, or are they whack?

    1. Re:What's the deal with nutshells? by Anonymous Coward · · Score: 0

      nutshells are AAAieeemftmftptangwalaueueueueueoouuuia!!

  26. dotNet / Java by Anonymous Coward · · Score: 0

    Yha,

    lord knows that Java or C# wouldn't allow you to write console or GUI apps.

  27. Moore's Law won't scale O(n^3) or similar problems by Anonymous Coward · · Score: 0
    Unless your time scales are geologic.

    In other words, scalability of an architecture will always be a factor for complex problems.

  28. Re:dfs style algorithm! by Anonymous Coward · · Score: 0

    Double prices
    Wait for Bank Holiday
    Halve prices
    Promote MASSIVE SALE!!!!!!
    Profit

    (sorry www.dfsonline.co.uk :)

  29. I can summarize it all by sfjoe · · Score: 1, Insightful

    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?

    --
    It's simple: I demand prosecution for torture.
    1. Re:I can summarize it all by smitty45 · · Score: 1

      seeing how they had pretty smart people writing the J2EE app they started with, I doubt #3. When you have the authors of "Tomcat: The Definitive Guide", and "Mastering Tomcat Development" writing your app, then I would assume at the very least that they are as good as any other Java team. I think people should consider the possibility that Friendster has/had scaling issues that other sites plainly don't have. All of their pages have to be dynamic, and I doubt that any of barely 1% would be cachable, besides images. I also think that people should consider the possibility that they don't have any idea why Java didn't work for Friendster, because frankly, they don't. And your app is only going to be as good as the stuff behind it.

    2. Re:I can summarize it all by Anonymous Coward · · Score: 0

      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?


      1. PHP scales exceptionally well, and while its scalability is not a feature of its language, the seamless integration with Apache and superior performance and reliability make it a good choice.

      2. Java MAY scale well, when the operating environment can be much more controlled. In the wide open world, Java is not as robust as PHP.

      3. Friendster could likely develop a PHP-based application in 1/10th the time it would take to develop a comparable application in J2EE, plus with PHP they have a larger pool of talent from which to cull developers and support.

      I'm really sorry you're having trouble finding jobs because you're a Java programmer. My advice is you start to learn PHP.

    3. Re:I can summarize it all by sfjoe · · Score: 1

      I'm really sorry you're having trouble finding jobs because you're a Java programmer. My advice is you start to learn PHP.

      Thank you so much for your valuable advice. I have learned PHP, as well as Java, and already have a job though.

      --
      It's simple: I demand prosecution for torture.
  30. PHP frontend and Java Backend by proudlyindian · · Score: 2, Informative

    JSR 223: Scripting Pages in JavaTM Web Applications
    The specification will describe mechanisms allowing scripting language programs to access information developed in the Java Platform and allowing scripting language pages to be used in Java Server-side Applications. JSR 223

  31. In other news... by sadiklis · · Score: 1

    ...SourceForge is playing with Java: http://www.sdtimes.com/news/105/story9.htm

  32. Re:dfs style algorithm! by Anonymous Coward · · Score: 0

    Urge.. to kill.. Linda Barker... rising....

  33. Scalability is Not a Language Feature by RAMMS+EIN · · Score: 3, Interesting

    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.

    --
    Please correct me if I got my facts wrong.
  34. Turk mmCache by Betcour · · Score: 1

    The Turk mmCache accelerator also provide a way to easely store and retrieve variables in shared persistant memory.

  35. What a waste. by Anonymous Coward · · Score: 0

    The article blows me away for all the wrong reasons. Regardless of the language chosen, it amazes me that the focus was on rewriting the application rather than performance testing and tuning the existing software.

    They missed out on some amazing diagnostic tools to help them understand what was happening in the code, deployed system, and IT organization. What planet do these people live on? Being a fantastic developer may help but it does not make one a performance or systems engineer.

  36. Operational Definition of Scalability you can use by Anonymous Coward · · Score: 0

    It is important to have a measurable definition of scalability. A reasonable definition of scalability for a given platform P and application A is

    S(A,P) = R(A,P) / C(A,P)
    where

    • R(A,P) = Maximum number of requests processed per second by application A on platform P,
    • C(A,P) = Cost of hardware and software to develop and support application A on platform P.

    Here I've assumed 100% availability for the purposes of this discussion. Availability could be added to the definition if desired. Note that this expression displays the expected behavior shown by common usage of the term "scalability":

    1. As throughput R increases, scalability increases,
    2. As cost C increases, scalability decreases,
    3. Different platforms and different software may be compared using this definition,
    4. You can use this definition to estimate costs of a proposed system, given an anticipated user load,
    5. Both R and C can be estimated using known techniques.

    With this definition, scalability's dimensions are "requests processed per second per dollar".

    Example: given the following known values for a single application A:

    running on platform X:
    R(A,X) = 1000 requests/second,
    C(A,X) = $40,000
    S(A,X) = 1000 requests/second / $40,000 = 0.025

    running on not-so-fast but less expensive platform Y:
    R(A,Y) = 500 requests/second,
    C(A,Y) = $10,000
    S(A,Y) = 500 requests/second / $10,000 = 0.05

    While platform Y's throughput (performance) is much less than that of platform Y, Y is much more scalable than (in fact is twice as scalable
    as) platform X when running application A.

    This definition can also be used to estimate the utility of using various software methodologies. For example, use of components or object technology or Java or PHP may or may not change the values of each factor in the definition: the degree to which each is changed determines whether the resultant system is more or less scalable.
    Michael D. Kersey

  37. Working link by Uninen · · Score: 2, Informative

    Here's an article from Jack Herrington on PHP's scalability

    And here is an actual link to the article.

  38. Scalability has little to do with language by PhotoBoy · · Score: 3, Informative

    Having developed systems in Java and PHP I think it's wrong to try discussing how well either of them scales without considering the main factors that affect the scalability of projects, namely:

    - The skill of the developers implementing the system
    - The foresight of the original plan/architecture design
    - Understanding of where bottlenecks/growth problems will occur

    Any project that doesn't plan the scalability in from day one will likely struggle to fix the problem when scalability does become an issue.

    IMHO scalability is a design and architectural problem, the language used (within reason) makes no difference- it's the quality and structure of the design itself which will make or break the system.

  39. Why the database should have fewer connections by Knight2K · · Score: 1

    Why would you limit your database to serving fewer connections than you have limited your web server to?

    I always wondered about that in application design. Just recently I talked with a former software architect from IBM and he gave me an answer that may make some sense. It still feels a little counter-intuitive to me, so any corrections would be welcome.

    The answer is basically a resource management issue if I remember correctly. You want to manage the load on your database servers so it stays relatively even, that is, avoiding peaks and troughs. You also want to keep requests waiting at the edges of your network, add the web server level.

    Imagine for a second a scenario where the database accepted an unlimited amount of connections. Eventually the database server would become swamped as more and more resources were consumed (database connections may not be quite as expensive as people think, but they still aren't free). At times you will have the servers running at 100% capacity and at other times at very low capacity.

    From a business perspective, you want to use the cheapest machines that are capable of meeting the performance goals. You could keep adding database servers until you meet the load, but this may not always be cost efficient. In addition, you then occur more overhead for keeping the database servers in sync with each other. So you can't just allow unlimited connections.

    Now consider the case I think you are stating. Let W web connections = D database connections. IIRCC one problem with this is that not all web requests require a call to the database, so essentially, you will probably have database connections going to waste. You are also wasting database server capacity and resources when you have a low traffic scenario since not all of the possible database connections are used.

    Think about it like getting assignments at work. Would you rather get a steady stream of assignments that you can finish in a reasonable amount of time? Or get dumped on with a million things to do at once, and then have long periods of inactivity. I know the clock on the wall seems to move faster to me when I have a steady amount of work to do and I have less stress when expectations are reasonable. Also, from my boss' perspective, when I have nothing to do, he is essentially paying me for doing nothing, and he doesn't want that.

    Another analogy might be the caching scenario. Caching is helpful because you can put data you are most likely to need in a location that is faster to search and quicker to access. But if your cache is the same size as your backend store (like memory matched to the size of your hard disk) you loose the advantage of fast searches since you have the same space to search. If your cache is too small you lose the access speed advantage since you have to go back to the underlying, and slower, store more often. So usually, you set the cache to be some fraction of the underlying store to maximize the search/access ratio.

    Database connections may not be dog slow, but they have more to do than a web server connection, which may have more to do than an edge-side static content cache. So you want to tune your application to find the optimal usage of each of your resources.

    So the IBM guy's answer was, you want to try and use a machine to around 80% capacity, so if the sh** really hits the fan you don't necessarily die, but you aren't maxed out either. By having the web server queue up requests to go to the database, you allow for a steady stream of traffic to the database, even at times when load is off-peak. This also means that it is easier to judge the affect of adding more hardware to the system, since you know how many pages you can serve at 80% capacity, so you know 1) when to add more servers (if the machines are constantly maxed) and 2) how many machines you have to add to keep the same quality of service.

    I think the point is the same as the performance vs. scalability discussions in the articl

    --
    ======
    In X-Windows the client serves YOU!
  40. Code scalability also important by tshak · · Score: 2, Insightful

    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?

    --

    There is no longer anything that can be done with computers that is nontrivial and clearly legal. -- Paul Phillips
  41. Mod Parent Up by Anonymous Coward · · Score: 0

    Dangit I just used my mod points in another thread

  42. Facts ? by Anonymous Coward · · Score: 0

    > Its difficult to argue with facts

    Not at all!
    You just grab a couple of other facts
    (that support your claim) and voila, you're done!

  43. "C/C++"? by tepples · · Score: 1

    <pet-peeve>
    There is no programming language called C/C++. There is a language called C, and there is a language called C++. If Yahoo! uses C++ backends, then it uses C++ backends.
    </pet-peeve>

  44. PHP is not always good enough (was Re:Yahoo) by Ogerman · · Score: 5, Insightful

    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

  45. Like your sig by yow2000 · · Score: 1

    tho it does sound a bit Soviet Russia. "Those who anger you, control you"

  46. Counterexample: Yahoo by Anonymous Coward · · Score: 0

    Show me a Java site that serves three billion page views a day.

  47. Yahoo by a mile by Anonymous Coward · · Score: 0

    Three billion pageviews a day and rising at a fair clip.

  48. PHP does not scale well, FACT by IonPanel · · Score: 1

    I used to be a PHP fantatic, but then I learnt Java, it is by far the better language, in terms of design, in terms of the architecture beneath it and performance. But by far the biggest reason why PHP doesn't scale is its raw basic types. Integers are at maximum 32-bit un-signed, that means when I was writing a simple file manager I couldn't handle files bigger than 4GB at all, and beyong 2GB PHP returned in-accurate results in terms of file sizes. Objects in PHP have always been an after-thought, same with most basic types in PHP. Unlike Java that was built from the ground up, much of PHP's functionaltiy has been tacked on at a later date without refactoring the project. PHP-5 does go some way to fix the problem, but it will never scale as well as Java does on any platform. Perhaps the best solution is like Yahoo, take the best of both worlds. Have PHP at the front, taking care of the final output is fine, but having it as the engine of your application is not always the best solution, and it certainly isn't for enterprise situtations.

    --
    Dave Bell
    1. Re:PHP does not scale well, FACT by IonPanel · · Score: 1

      Sorry, I meant 32-bit signed integers.

      --
      Dave Bell
    2. Re:PHP does not scale well, FACT by Anonymous Coward · · Score: 0

      What the hell are you doing messing with 2GB+ files in a Web Scripting language? Are you insane?

      And did you file a bug?

    3. Re:PHP does not scale well, FACT by prockcore · · Score: 1

      Integers are at maximum 32-bit signed

      Actually, integers and floats in php are whatever the native integer and floats are for the platform.

      On a 64bit platform, integers are 64 bit signed.

      Plus there are bigmath libraries for any size integer, just like in perl.

    4. Re:PHP does not scale well, FACT by IonPanel · · Score: 1

      Yes, and? I use a 32-bit platform, but that doesn't stop me using 64-bit numbers. Java supports them, so why can't PHP?

      --
      Dave Bell
  49. php scalability and memory by Anonymous Coward · · Score: 0

    On a php apache installation php does not handle that many requests before running out of memory.

    This is with the apache prefork method. Allthough if you are careful you can use the threaded model.

    It is easy to write applications not using php which can handle 10x as many users on the same machine. Mainly because apache/php gobble up your memory too quickly. However there are also ways to make your php/apache site scale better without getting more hardware.

    Use seperate apache installs specialised for each request. eg. Compile one apache with almost nothing compiled using the threaded mpm for static files/images. Use proxying(with squid or apache) to direct requests however you need to. Use different webservers when you need to. The good thing about setting up proxying on the same machine is that if you need to scale to more machines it is fairly easy.

    Modularity is good. If there are any parts of your site which you can seperate, do so. Some common examples of things that can be moved include statistical reports(for the pointy haired bosses). Again if you keep things modular on the same machine, you can easily move those parts to seperate machines later. The more things you can keep modular the better!

    Use an in memory db(or precache your disk db), with periodic syncing to disk for backup. For lots of cases *YOUR DATA IS CRAP* so don't bother too much trying to ensure that it gets written correctly. Reading/writing data from the hard disk is *slow*. Try and keep all your data in ram. Besides, with uptimes of 300+ days on an average linux/bsd box you will probably only loose one backup interval of data a year.

    Repeating it again in case you missed it *YOUR DATA IS CRAP*.

    Use a faster db for simple storage needs. eg use a bsddb database instead of an sql one.

    Use mod_gzip/mod_compress to get your slow modem clients off your back quicker. Slow modem users sucking down big php pages can tie up apache processes using up memory slowing you down. If you get their content to them 8 times faster you can start serving another client quicker. As a bonus the users will think your site is 8 times faster! **holy cow this site is fast now!!!!**

    Remove all unused apache mods. Try recompiling php to use less memory. If your sites do not need the GD image libraries, do not compile them in. With a bit of tweaking you should be able to use half as much memory.

    On the client side, use javascript/flash!!! You can reduce the number of requests/page loads dramatically by doing things dynamically on the client side.

    A js eg. Whilst writing a response to my post clicking the preview button should *not* need to make a http request, do some processing, then spit back the answer. For clients with javascript enabled simply have the preview code as javascript. Now you just cut the number of post related requests down by at least half!

    Have fun!

    1. Re:php scalability and memory by smitty45 · · Score: 1

      I don't think you have any idea how much bandwidth/memory/db size Friendster uses.

      In-memory databases are not a possibility, and caching is impossible.

    2. Re:php scalability and memory by Anonymous Coward · · Score: 0

      uncacheable.

      and what if one machine goes down, or one ramdisk has corruption ? you replicating those 10 machines ?

  50. STFU and RTFM for zealots of php... by Anonymous Coward · · Score: 0

    "If the only tool you have looks like...."

    Hammer meet nail, nail meet hammer.

    Hammer I'm sorry you can't meet screw we already know what will happen don't we....

    http://www.sys-con.com/story/?storyid=45250
    and
    http://kano.net/javabench/

  51. It's not the language or the toolkit! by daBass · · Score: 1

    So, the author basicaly states PHP scales better than Java because it does not have sessions. So how about not using sessions in Java either? You don't _have_ to use them, you know!

    If you have a replicating database backend, use database connection pooling and stay away from sessions, you don't have the inter-JVM messaging problem.

    When you do that, you can add as many database and web servers as you want, this is the same for Java and PHP.

    Not that I believe Java is a superior solution to PHP, both loose out badly compared to AOLserver in the performance and ease-of-coding department.

  52. php scalability and memory by Anonymous Coward · · Score: 0

    I have no idea how much bandwidth/memory/db size Friendster uses. So lets make up some random numbers ;)

    Assuming 100,000 simultaneous active users each consuming 100kb of data that works out to be under 10 gigs of memory. Put it up to one megabyte per user and that is around 100 gigs.

    You can easily fit 16 gigs of memory in one machine. If you use ram disks you can even fit more than 16 gigs of memory. Put in ten machines and you should be able to service a lot of users.

    Have fun!

  53. Have some kibble by Safety+Cap · · Score: 1
    The rest of your comment at least makes a little sense, but that makes it seem like you have no idea what scalability means.
    My quick-'n'-dirty definition of "scalability": increasing the load capability (i.e., number of visitors/page views/amount of data per second/minute/day/whatever) of the service by throwing hardware or other resources at the problem and/or by distributing the load across existing servers.

    If you design and code MVC and want to scale up and you're colo'ing in the same place, you simply add a new boxxen (web/application server) V/C and use the original M. If you're hosting at a new location far enough away that latency issues start raising their ugly little heads, then you need to do something else (host multiple Ms and do some kind of batch data reconciliation or slow-link updates).

    On the other hand, your Model 1 guy can't do any of that because the M is hopelessly wedded to the V, so there's no way to add additional V/Cs without risking deadlock or eventual mismanaging of your singletons (one M gets updated and others don't, mix, repeat).

    --
    Yeah, right.
  54. Read-write sharing over NFS does not scale by brlewis · · Score: 1

    Obviously the NFS solution would not scale very well horizontally. "Imagine a beowulf cluster of these" all wanting a lock on the same NFS file at the same time. A database session driver might scale somewhat better, but couldn't you do the same thing with Java?

    The best solution is to eschew the whole "session" model as much as possible. The article seemed to imply that PHP encouraged this, but I'm not convinced. I think I've seen plenty of PHP tutorials encouraging session variables unnecessarily.