Forgot your password?
typodupeerror
PHP Programming Java

PHP Scales As Well As Java 627

Posted by michael
from the emperor-has-no-clothes dept.
mactari writes "Jack Herrington at the O'Reilly Network has had the audacity to claim that both PHP and J2EE architecture... are converging on the same design [regarding scalability]. Can it be that he's disproven the idea that 'Java scales and scripting languages don't' when he says, 'The idea that PHP does not scale is clearly false at the performance level'? Even if a little oversimplified (ignores horizontal scaling), it's an interesting comparison that takes a peek at the architecture beneath both hypes."
This discussion has been archived. No new comments can be posted.

PHP Scales As Well As Java

Comments Filter:
  • by Anonymous Coward on Friday October 17, 2003 @12:01PM (#7240339)
    And the other recent additions that add to the scalability of Java?
  • Scaling (Score:2, Insightful)

    by stanmann (602645) on Friday October 17, 2003 @12:01PM (#7240341) Journal
    Java and PHP Scale equally well... Well that isn't a big surprise since Java as I understand it doesn't scale very well..
  • Re:Scaling (Score:3, Insightful)

    by Frymaster (171343) on Friday October 17, 2003 @12:06PM (#7240419) Homepage Journal
    Java and PHP Scale equally well.

    as a corollory, it is much easier in php to write code that itself does not scale well. contrary to popular belief, php is not a language for sloppy or new programmers - to write a robust, secure, scalable app in it you have to know what you are doing!

  • by bigjocker (113512) * on Friday October 17, 2003 @12:13PM (#7240508) Homepage
    What I would love to see is a 100,000+ lines project written in PHP being mantained by one or two developers. You can't do that without strict typing.

    PHP is perfect for small projects, but when you have huge requerements and a ton of lines to mantain, that's when the real scalability shows off. You can build a 1,000,000+ lines project in PHP and run it on a distrubuted server and whatnot. But who the hell is going to mantain it??
  • by digidave (259925) on Friday October 17, 2003 @12:15PM (#7240536)
    Java scales up very well, PHP scales down better.

    If you're trying to run on a budget where you can't add a ton of servers and are limited to aging technology, Java will not scale to that environment very well. PHP can do quite well there.

    Sun isn't interested in that market, which is a shame because there are a lot of companies still cutting budgets. I'd love to buy a server newer than a P2 1ghz, but it's not going to happen until at least next fiscal and even then, unlikely. We don't all work for technology companies who understand or care.
  • by Dr. Bent (533421) <[ben] [at] [int.com]> on Friday October 17, 2003 @12:17PM (#7240560) Homepage
    ...then yes, it does. However:

    "PHP can use the database as the back-end session store."

    and

    "The ideal multi-server model is a pod architecture, where the router round-robins each of the machines and there is only a minimal session store in the database."

    are pretty tough assumptions to swallow. Storing session state in a database only works when you have a small amount of session state to store. Otherwise the database quickly becomes the bottleneck for any operation you need to perform. The alternative is that you have to have your session state distribuited in a cluster, which is something that, AFAIK, you cannot do in PHP. You can, however, do it Java. In fact, some of things that JBoss is trying to do [jboss.org] will make session replication across a cluster fairly easy.

    PHP can be very useful. I think PHP as a view layer sitting on top of a a J2EE controller and object model would be a wonderful idea. But to say "PHP scales as well as Java" is a huge oversimplification of the extremely complex problem that is enterprise computing.
  • by DrEldarion (114072) on Friday October 17, 2003 @12:18PM (#7240573)
    When I read the story above, I saw "Jack Herrington at the O'Reilly Network has had the audacity to claim that ..." and thought to myself, "why would the person who submitted this write it like that?".

    Then I read the comments, and it seems that people actually get seriously OFFENDED by statements like that! You're reacting almost as if the guy insulted your mom! Calm down... breathe...

    -- Dr. Eldarion --
  • by BigGerman (541312) on Friday October 17, 2003 @12:19PM (#7240584)
    "A page showing ten fields from twenty objects would make two hundred RMI calls before it was completed."
    Sure if it was coded by former vb guy w/o a clue.
    Even naive J2EE applications I saw would be smart enough to use a view object (containing all twenty business objects and their fields) to come back from the buisness layer in one call.
    A person to use argument like this about J2EE scalability has no credibility whatsoever.
  • by jbottero (585319) on Friday October 17, 2003 @12:24PM (#7240636)
    I'm not sure what your point is or how you got there. How is maintaining 100,000 libes of PHP any different than 100,000 lines of any other code? The fact that PHP has very much in common with C syntax should make it even easier. But really, what are you, a VB programmer?
  • by Waffle Iron (339739) on Friday October 17, 2003 @12:24PM (#7240638)
    What I would love to see is a 100,000+ lines project written in PHP being mantained by one or two developers. You can't do that without strict typing.

    Maybe with dynamic typing, that would only be a 30,000 line project.

  • Re:Some facts (Score:5, Insightful)

    by vlad_petric (94134) on Friday October 17, 2003 @12:28PM (#7240682) Homepage
    But connection pooling scales much, much better than persistent connections ... Especially when each user makes only a couple of requests.
  • Hrm (Score:5, Insightful)

    by Etriaph (16235) on Friday October 17, 2003 @12:29PM (#7240689) Homepage
    The issue with PHP is not whether or not it scales as well as Java, but whether or not it's useful in a real-world application. In my opinion, it isn't that useful.

    PHP offers us no way to build an application server (unless you write one in C or C++ and send commands to it via a cli or directly through sockets). If you embed Tomcat in your application server, you can simply create contexts and mount them with mod_jk. Quite simply, you can take any server that you've written in Java and web enbale it fairly quickly. PHP lacks persistence, and I'm not talking about sessions.

    Let's say that we want to add a request to our application from the web. With Java I can toss the request on a queue which a thread picks up and balances to several other worker threads who interpret the request and works with it. With PHP I would have to enter data into a flat file, or a database, and have a cronjob setup to run every minute or so and do something with data in the database. Even then, at that point, I can only have one thread unless I want to mix and match several cronjobs to run at seperate times (or unless I want to fork the process off very uncleanly using exec() or system()). In any case, does PHP scale as well as Java? Maybe, I'd need to do more tests. Is it nearly as useful? No, not right now, probably not ever. Unless you are willing to write your own custom PHP module in C and play with PHP that way, I think big jobs should be left to the heavyweight in this discussion.

  • by Anonymous Coward on Friday October 17, 2003 @12:32PM (#7240723)
    How is maintaining 100,000 libes of PHP any different than 100,000 lines of any other code?
    PHP doesn't have strict typing, so it's harder to maintain.
  • Apples to Oranges. (Score:3, Insightful)

    by SatanicPuppy (611928) <.moc.liamg. .ta. .yppupcinataS.> on Friday October 17, 2003 @12:34PM (#7240753) Journal
    Php and Java aren't the same kind of language, so why do people insist on trying to compare them? Php works great for a lot of applications, but expanding its function base is a fricking nightmare, and you're dealing with a certain amount of compile time overhead on every page view.

    With Java you have easy access to a lot of OOP features that are very difficult to implement in Php, and the function base is simple to expand. Yea it's big and beefy, but that's what you need sometimes.

    They're both just tools. Use the one that's appropriate. People scream about Java being bad for small pages. What kind of idiot is using Java on a small page? Conversely I've never even heard the Java vs Php agrument for a big site--it's always Java vs VB, and that's another no brainer.

    Just my opinion.
  • Re:Props to PHP (Score:2, Insightful)

    by letxa2000 (215841) on Friday October 17, 2003 @12:51PM (#7240933)
    I'm just sick of having the tools specified for me as part of the job, when I know I could do it faster,cheaper and better if I were allowed to choose my own platform. Repeat this a couple of times and you get mad at the tools.

    Then start your own company, or become an independent consultant and take the contracts you are interested in.

    There is more at stake in any given project then what YOU can do faster since there are probably other people that can do it faster with the tools they want to use. If you are in a company and have an opportunity to promote the technology or language you think is best, do it--but don't make "because I can do it faster" one of your arguments. Unless you *ARE* the development team it really doesn't matter what you can do faster. Maybe you're not the right person for this job.

    I'm an independent consultant and I often peruse job sites to see if there are any interesting consulting jobs out there. I've actually never found one using those sites, but I often see lots of entries for ASP work, etc. I obviously don't bother contacting them and try to convince them, "No, I don't do ASP. But what you REALLY want to do is..." That won't work. I just move on and find a company that coincides with what I agree is the better solution. Fighting the powers-that-be to use a different language is a high-stress, tiring proposition and what I want to do is develop, not campaign.

  • by stesch (12896) on Friday October 17, 2003 @12:54PM (#7240976) Homepage
    Why don't you try Resin?

    Maybe he doesn't want to spend lots of hours to change his code every time a minor release of Resin comes out. And then discovering new problems many weeks later.

  • by mark_lybarger (199098) on Friday October 17, 2003 @12:56PM (#7240995)
    i've used PHP, and it's a bitch to debug and to understand in general. it's nice for script kiddies, but outside of that, i'd leave it alone. java isn't really a good tool for websites either though, at least not java's jsp. There's many nice templating engines available under java which are VERY nice for dynamic sites (velocity, freemaker, etc). Let java handle your business logic, and let templates run your user interface.
  • by brlewis (214632) on Friday October 17, 2003 @12:58PM (#7241027) Homepage

    The problem with PHP isn't dynamic typing, it's loose typing.

    Scheme has strict dynamic typing. You get more concise code, but not so error prone as PHP.

    Java has strict static typing, possibly somewhat less error prone, but less convenient.

    Languages like ML have strict static typing, but type inference makes the code more concise.

  • by Eric Savage (28245) on Friday October 17, 2003 @01:27PM (#7241281) Homepage
    I think you are confusing Java with applets. JSP (especially under Resin) is so fast and so efficient that I still have a hard time believing that some of the servers I work with can keep up. One is running a data-driven applicatino on a PPRO180 handling 8-10000 sessions a day, thats just crazy.

    PHP has it's place, its great for multi-user web hosting companies where Java's architecture is a poor choice. It's not great for enterprise development, and every time someone who is fresh off writing their forum site suggests it I just have to pull out the long list of security problems PHP has/does have and the discussion ends immediately.

    Why do PHP people feel the need to get into enterprise development? Java people aren't out there pushing for fansites and homepages to switch over, because they know its a bad choice.
  • by crazyphilman (609923) on Friday October 17, 2003 @01:32PM (#7241319) Journal
    I think you're mixing two concepts here. First, there's Java/J2EE. You can do Java without doing J2EE. J2EE is a whole set of additional tools and ideas which are java-based. My impression of it is that it's more useful to huge organizations like banks, where you've got different servers in different buildings which have to interoperate (hence things like javabeans and servlets). It's not a scalability thing, it's a distributed application thing, you know? Although I'm sure J2EE has scalability features built into it, I don't think scalability is the whole point of J2EE.

    On the other hand, if you're talking about just scaling to larger numbers of users, you're probably talking about load balancing more than anything else. One server will basically be handing off requests to other servers based on how busy they are. That has nothing to do with Java Vs. PHP. You can use either with that. The only gotcha is you should make your pages stateless (no session variables, etc). If you pass data from one page to the next, do it the old-school way using hidden form elements, because then no matter which server gets handed the current request, you'll have the passed-along data and you don't have to futz around with the session.

    My thinking is, as long as your scalability has to do with load, just worry about load-balancing, make your pages stateless (there IS state, but you're passing it along on form posts rather than trying to store it on the server), and use whichever language has been working for you up until now. Don't touch J2EE (or .Net, or any other buzzword) unless you actually *need* it, like for example, if your app is distributed and very complex.

  • by Anonymous Coward on Friday October 17, 2003 @02:01PM (#7241627)
    No I think he is just talking about GENERICS which won't replace the strong typing but just used as another language contstruct to make things a little easier....
  • Strict Typing (Score:2, Insightful)

    by jbottero (585319) on Friday October 17, 2003 @02:09PM (#7241697)
    "PHP doesn't have strict typing, so it's harder to maintain."

    That's not a language issue, it's a programmer issue. Learn good habbits.
  • Re:Perl (Score:3, Insightful)

    by pHDNgell (410691) on Friday October 17, 2003 @02:28PM (#7241931)
    Perl seems to scale as well--it runs a very busy site [slashdot] I frequent with few problems.

    I've been having a great deal of broken pages lately.

    I also have been having a lot of problems with the RSS feeds lately.

    Overall, I like using slashdot as an example of why mySQL and perl are bad ideas for busy sites.

    Any language can be used to write bad code, but I've rewritten really perl projects (2M line range) that were impossible to maintain into java (for example) applications that were not only easier to manage, but performed better.

    Whether raw perl is faster than raw java, who knows or cares? When I want raw speed, I write apps in ocaml (or C if I need slightly more speed). When I want to prototype something quickly, I write apps in python. When I want to build a large scale application, I use java (and python for parts). With a proper design, going from one application server to two doesn't double the strain on my database server (not even close), but usually doubles my capacity. It also doesn't require a rewrite of the app.

    Then I start making things happen asynchronously with threads and message queues. These days, my apps are looking more like mainframe apps from performance monitors. We maintain a pretty high load here, and I watched it triple during some event for a few minutes. Processing speed was constant due to surge protection I was able to make using a simple thread and a linked list. For our most common type of database work, there is no more than one insert/update occuring per application server instance. That makes such a huge difference.
  • Re:Here's why... (Score:3, Insightful)

    by mikeg22 (601691) on Friday October 17, 2003 @02:36PM (#7242038)
    We have a 500,000+ line VB project that is very GUI intensive and it works/scale quite well. OO is good for some applications, but its more work than its worth for others. There are places in our project where having inheritence would be very helpful, but we have designed around this limitation. Threading for would have limited use as well. The ease of the GUI building more than makes up for the threading and OO limitations, at least in our project.

    I'm not sure if your post was a troll or not, but it is pretty arrogant to assume any one language, especially one as widely used as VB, is for "kiddies."
  • Re:Here's why... (Score:2, Insightful)

    by Deacon Jones (572246) on Friday October 17, 2003 @02:45PM (#7242157)
    I am a developer for a fortune 500 company with 110,000+ employees
    and

    Can I create a class and inherit from it?
    So your Fortune 500 company obviously hasn't heard of VB.Net, I take it?
    I have no dog in the language semantics fight here, but most of your points are valid pre-.Net days, which means your points are invalid.

  • by Anonymous Coward on Friday October 17, 2003 @04:27PM (#7243571)
    What a unique opinion..anyway you wrote..

    You have no clue what enterprise class means. I am a developer for a fortune 500 company with 110,000+ employees.

    I work for an Ivy league medical college, and the application that is used to track all of the medical students in the US is written in VB. Plus the hospital we are affilliated with writes some apps in VB also. Maybe you don't use VB for large apps, but that doesn't mean no one does.

    Personally, I like VB but I work with Java. It is a waste of bandwith to write posts flaming away at people and personally attacking them based on your own personal preferences. Yet that is half the posts on slashdot. Yes I know, I must be new here. (here comes the guy with the "new here" handle).
  • by Anonymous Coward on Friday October 17, 2003 @04:36PM (#7243686)
    Obviously you are referring to VB6 and earlier and not VB.Net, which is a true object-oriented language (with the same lame syntax) so I won't go into any more of that.

    I am a developer for a fortune 500 company with 110,000+ employees.

    That means absolutely nothing in terms of credibility-- Fortune 500 companies do hire idiots, too.

    However, many "enterprise" applications consist of a simple program running on the client (like a VB program) and all it's doing is transferring data to and from a back end database. You don't NEED a powerful language on the client side, if all of the magic is done with stored procedures and you're just displaying it.

    But being from a Fortune 500 company with 110,000+ employees, you probably knew that.

    running perl can handle the load that many other sites out there just crock on

    Maybe it has something to do with the fact that Slashdot is hosted on 8 load balanced web servers (3 of which are dedicated to images). And you're comparing slashdot's ability to handle load compared to some dinky little server that gets slashdotted easily? I've got news for you... even cgi/perl boxes get slashdotted. It's all about the hardware. Sorry.

    Thats part of the problem right there. If you dumb down a language too much such as VB, you loose all the power features that comes with a language such as C, C++. It also contributes to all the headaches in the world of IT when you have tons of piss poor code written by sup-par "programmers" that cannont grasp anything harder then VB. Trusting a VB-only developer to write an Enterprise class application is like having the "tire change boy" be your machanic. It is a stupid choice to make.

    You are obviously an intern, or fresh out of school, and haven't had a lot of real world work experience yet.

    Yes, VB makes it easy to write bad code that still somehow manages to work. Many languages do. Believe it or not, it is possible to be a GOOD programmer and write in VB.
    If you were a real programmer, you would know that good programming is about HOW you use a language vs. whether you use it, because often you simply don't have a choice in the matter (unfortunately).

  • by SlightOverdose (689181) on Friday October 17, 2003 @10:38PM (#7246195)
    Python, Perl, PHP, Ruby... Thats four object orientated languages without strong typing, all of which have an extremely happy and loyal fanbase, and theres a lot more.

    Just for once, I'd like to see someone explain why strong typing is so important. I develop most of my code in Python, and I have yet to see any problems. Hell, I find strong typing restrictive as it prevents me from doing things I otherwise should do. I'm currently working on a project of (according to cat | wc -l) 320812 lines, an god knows how many classes. I've yet to have one bug related to the lack of strong typing.

    So heres my challange to all you strong typed zealots. Explain why it's so important!

Is a person who blows up banks an econoclast?

Working...