Forgot your password?
typodupeerror
PHP Programming Java

PHP Scales As Well As Java 627

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

      • by Camel Pilot ( 78781 ) on Friday October 17, 2003 @12:42PM (#7240847) Homepage Journal
        In my experience strict typing has little to do with maintenance issues.

        I would rate design, proper partitioning, data packaging, code quality, etc. way above strict typing. In fact strict typing typically adds 10% to 20% code bloat to your application. Besides script typing is more for the benefit of the compiler and not the human developer.

      • by tshak ( 173364 ) on Friday October 17, 2003 @12:53PM (#7240963) Homepage
        I used to code in Perl, Cold Fusion, and VBScript (ASP) back in the days that scripting was all the craze. I used to love (believe it or not) working with Cold Fusion. I could create a web application so quickly, and it had features like connection pooling, session management, and application management right out of the box (and this was 5 years ago).

        Once clients started demanding "web applications", as opposed to basically static web pages with a little DB interaction, I quickly realized how no scripting solution would scale elegantly. Most people (at the time) would scoff at the idea of writing even a 10K line of code app with Perl/TK, why did we do the same with web apps?

        I think the number one reason that scripting sucks for application development of any sort is it's lack of strict typing. This makes it difficult to implement a clean OO design, and it also makes it harder to code IMHO. Sure, there's the extra step of compiling, but that actually helps me track bugs in my code down quicker. Even for small projects I hesitate to use a scripting language because you never know what part of that project you'll want to reuse, or if that project will grow in the future.

        So, while most of my resume contains scripting experience, I would have to say that my life as a "web developer" is much better now that I'm working with C# and Java.
      • What I would love to see is a 100,000+ lines project written in PHP being mantained by one or two developers.

        find . -name "*.p" -o -name "*.htmp" -o -name "*.html" -o -name "*.php" | xargs wc -l
        91564 total

        current staff: two php developers. two flash developers.

        close enough?

        (nb: .p and .htmp are php pages... it's a legacy requirement.)

      • The scalability and maintainability of a project ove r a period of time most importantly depends on the quality of code and documentation within code (Comments).

        I have seen so much java code, so badly written that the developer who wrote it 6 months ago, was also hesitant to touch it.

        While on the other hand, I have seen hugh shell scripts being maintained over a period of 10 years.

        If the code to be maintained is poorly written and ill documented , then no matter wheather you use strict type checking or not, it will be a nightmare to maintain.

  • 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!

    • Apples to Oranges. (Score:3, Insightful)

      by SatanicPuppy ( 611928 ) <Satanicpuppy AT gmail DOT com> 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.
  • by Keck ( 7446 ) on Friday October 17, 2003 @12:03PM (#7240365) Homepage
    pudding is as good of a building material as tofu..
  • of course it does... (Score:3, Interesting)

    by joeldg ( 518249 ) on Friday October 17, 2003 @12:04PM (#7240386) Homepage
    we use PHP here for huge web applications.. we have six servers pumping out one website and it connects to a redundant database server.

    The same system in java probably would not work, and if so would take up so many resources as to be no efficient.

    If you are interested in more examples of some somewhat crazy things you can do in PHP check here [intercosmos.net] to see examples of using it on the commandline for ncurses (which I wrote the primary tutorials on zend.com for) and for handling sysv shared memory.

    Cheers

    • by Fweeky ( 41046 ) on Friday October 17, 2003 @12:08PM (#7240445) Homepage
      The same system in java probably would not work, and if so would take up so many resources as to be no efficient.

      Um, why not? A JIT compiled Java application server with the ability to perform object pooling and the like should outscale PHP in it's sleep, and probably be significantly faster at all levels to boot. If it does anything else, you did something wrong.

      (Personally, however, I'm really favouring Ruby/FastCGI over both at the moment)
    • 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.
  • yeah whatever (Score:2, Informative)

    by TedCheshireAcad ( 311748 ) <.ude.tir.cf. .ta. .det.> on Friday October 17, 2003 @12:04PM (#7240387) Homepage
    I call bullshit.

    PHP is a useful language, and it certainly has its place. But for large enterprise applications, it can't hold a candle to J2EE, in terms of speed and scalability. If you drop some serious bank on an application server, you'll know what you're paying for.

    Moderators, have mercy.
  • by defile ( 1059 ) on Friday October 17, 2003 @12:04PM (#7240390) Homepage Journal

    I thought the shocking revelation would have been "Java scales as well as PHP" under pathologically slanted circumstances.

  • by sporty ( 27564 ) on Friday October 17, 2003 @12:06PM (#7240410) Homepage
    W/o fine grain controls such as managing the persistent connection pool to resources...

    No, it's not.

    That's not to mention all the other architectual mishaps within the language. You thought perl was bad..
  • by SCHecklerX ( 229973 ) <greg@gksnetworks.com> on Friday October 17, 2003 @12:08PM (#7240444) Homepage
    I'll stick with mod_perl and HTML::Embperl, thanks.
  • by Faramir ( 61801 ) on Friday October 17, 2003 @12:09PM (#7240458) Homepage Journal
    Okay, talk about asking for a flaming! I'm a PHP developer whose done a bit of Java but knows nothing about J2EE. Can someone explain how this is relevant to me, as I start looking at larger applications with hundreds, perhaps thousands of users?
    • by jsse ( 254124 ) on Friday October 17, 2003 @01:25PM (#7241264) Homepage Journal
      I'll try.

      Performance-wise, J2EE decouples major components which would otherwise become bottleneck of overall performance. E.g. most popular architecture decouples frontend(e.g. load-balancer, apache), business logics(e.g. servlets, EJB-containers) and database(e.g. Oracle, Sybase) such that optimization could be done on individual components. Optimization can be ranged from adding CPU/RAM, disk stripping to clustering. Experience told us that this architecture can be very sucessful in improving performance and scalability.

      I can't really disgree on the critism on the raw speed of Java, but as you may see J2EE successfully spreads the loading among entire framework, which lead to huge gain in overall performance.

      I'm not going too deep into design and implementation issues here, as they might be off-topic this time. However, as you can see, design and implementation can be done seperately on each components as listed above.

      Frankly, I'm not so sure if PHP has gone that far.
    • 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.

  • Yahoo! (Score:4, Interesting)

    by nocomment ( 239368 ) on Friday October 17, 2003 @12:09PM (#7240464) Homepage Journal
    Well seeing as Yahoo is switching [yahoo.com]over to php, from C no less! Plus if you want to, you could use slashdot as an example of scripted sites. Of course slashdot at random interval won't load for about 10 or 15 minutes (rarely longer).
    • by kevin_conaway ( 585204 ) on Friday October 17, 2003 @12:19PM (#7240583) Homepage
      If you read the article, they mention the only reason they arent using Java is because FreeBSD doesnt have decent threads support. Perhaps if the major bulk of their systems ran a different OS, they might use j2ee?
      • by nocomment ( 239368 ) on Friday October 17, 2003 @12:33PM (#7240742) Homepage Journal
        I read that, it doesn't _exactly_ say they aren't using it because of the threads but more like, they aren't considering it because of threads. It wasn't even an option to be included in the benchmark tests. Although if they weren't so stuck on FreeBSD they _might_ choose j2ee. That would be a big boon for Sun if they did :-)
  • Perl (Score:3, Interesting)

    by rmohr02 ( 208447 ) <mohr,42&osu,edu> on Friday October 17, 2003 @12:10PM (#7240468)
    Perl seems to scale as well--it runs a very busy site [slashdot.org] I frequent with few problems.
    • 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.
  • Some facts (Score:5, Informative)

    by vlad_petric ( 94134 ) on Friday October 17, 2003 @12:10PM (#7240477) Homepage
    1. Scaling != performance. Scaling simply means that if you multiply the hardware by n you should be getting (ideally) close to throughput *n.

    2. DB is the bottleneck for most websites. A good connection pooling and caching system are critical. Ahem ... last time I checked, Java did considerably better than PHP in terms of both.

    3. As PHP was not designed as a multipurpose language, sometimes a PHP-only solution is simply a kludge. PHP's power is in writing webpages quickly, if you want to do, for instance, something more complex like charting in a web page (well, in a .PNG), things can get messy. Yeah, you can do that in C, but what's the point ?

    • Re:Some facts (Score:3, Informative)

      by consumer ( 9588 ) on Friday October 17, 2003 @12:24PM (#7240637)
      PHP provides persistent connections, so the system does not need to reconnect to the database on each hit. It also provides various caching tools, like memcached [danga.com]. Charts and graphs are typically handled with third-party libraries. It's not exactly hard.
    • by Ian Bicking ( 980 ) <ianb&colorstudy,com> on Friday October 17, 2003 @12:58PM (#7241030) Homepage
      Besides the ability to inline PHP in static text, PHP isn't particularly bound to HTML output. It's not a specialized language -- ironically, it's a rather crappy language for generating HTML. It's quoting and substitution rules suck, it's regular expressions are a pain to work with (more quoting problems), and stuff like magic quotes are both insecure and unpredictable. PHP as a language sucks in lots of other ways, it was designed by people for which it was their first programming language implementation -- it's naively designed and it shows. But it sucks in a surprisingly multipurpose way, even for HTML generation.

      PHP's runtime environment is tied closely to mod_php and the Apache environment. Mostly no one cares enough to change that, I suppose, because it's not that fundamental of a design.

    • by namespan ( 225296 ) <.gro.liametile. .ta. .napseman.> on Friday October 17, 2003 @01:06PM (#7241111) Journal
      1. Scaling != performance. Scaling simply means that if you multiply the hardware by n you should be getting (ideally) close to throughput *n.

      Isn't this just the same as saying "scaling" means that the software uses the hardware efficiently -- which would then be true for both PHP and Java to similar degrees?

      2. DB is the bottleneck for most websites. A good connection pooling and caching system are critical. Ahem ... last time I checked, Java did considerably better than PHP in terms of both.

      You know, I was going to respond to this, but then I realized I didn't know what connection pooling actually means....

      • Re:Some facts (Score:3, Informative)

        by crazyphilman ( 609923 ) on Friday October 17, 2003 @01:37PM (#7241379) Journal
        Connection pooling means, basically, that the server sets up a pool of already open connections to a database, and your app can borrow a connection from the pool when it needs to interact with the database, then release the connection back to the pool. It's a performance trick, because opening a connection and closing it eats up resources, so you open up all the connections at once and leave them open, and they just handle requests which is less resource-intensive. I haven't had much need for it myself, but I've read about 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@NOSPAm.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 consumer ( 9588 ) on Friday October 17, 2003 @12:29PM (#7240685)
      All of the Java "best practices" stuff is full of warnings about how storing anything significant in the session will kill your performance. It's a huge mistake. Only truly transient data belongs in the session, regardless of language. And yes, PHP has various ways of doing distributed sessions, but frankly this sort of thing is overrated. It's VERY hard to go faster than MySQL with MyISAM tables for this kind of simple shared data.
    • Session state (Score:3, Interesting)

      by JMZero ( 449047 ) on Friday October 17, 2003 @12:41PM (#7240828) Homepage
      Storing session state in a database only works when you have a small amount of session state to store

      I think developers need to commit to smaller session footprints on servers anyway. Our goal here is to have nothing but security information stored on the server - and I think that's very reasonable. Make everything else come on the request.

      We see a lot fewer bugs this way, and everything becomes easier to maintain. The database can handle the login information fine (thus far at least - our applications are all very data intensive to begin with), and being in the database means session info is easy to manage.

      To me, having another a session quasi-database replicated around the cluster seems like an ill-fated enterprise.

      Web development, though, is like that I guess. It's always difficult to picture what works for applications different than your own. The 100,000 lookers at site A call for a different setup than 10,000 workers at site B might need.
  • Comment removed (Score:3, Insightful)

    by account_deleted ( 4530225 ) on Friday October 17, 2003 @12:18PM (#7240573)
    Comment removed based on user account deletion
  • 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 tmhsiao ( 47750 ) on Friday October 17, 2003 @12:26PM (#7240664) Homepage Journal
      Sure if it was coded by former vb guy w/o a clue.

      Welcome to the Real World.
    • by beavis88 ( 25983 ) on Friday October 17, 2003 @12:34PM (#7240757)
      Someone at a company we partner with wrote a web service, part of which made 400+ RMI calls to validate the input on a single (enumerated) field. Yeah, he probably was a former vb guy,and certainly had no clue, but this was in the "Real World", and it made it all the way to release before they noticed it (the staging tiers we all on the same server, the prod tiers were not...)
    • by consumer ( 9588 ) on Friday October 17, 2003 @01:03PM (#7241066)
      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.

      Doesn't this just illustrate how absurd it is to use RMI for this kind of thing in the first place? It forces you into workarounds likes this, and makes you use ugly coarse-grained interfaces instead of standard OO practices.

  • by mccalli ( 323026 ) on Friday October 17, 2003 @12:21PM (#7240603) Homepage
    From the article: "Yet another area of efficiency concern is in the connection between the language and the web server. "

    Only for web applications. If the argument is that PHP can serve up HTML as fast as Java can, then I imagine he's right. But there's a lot more to the world of programming than shoving out HTML.

    Cheers,
    Ian

  • Hrm (Score:5, Insightful)

    by Etriaph ( 16235 ) on Friday October 17, 2003 @12:29PM (#7240689)
    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 brlewis ( 214632 ) on Friday October 17, 2003 @12:31PM (#7240710) Homepage

    Back when I was concerned about whether BRL [codesimply.net] had decent performance, I did a simple benchmark on a 586 Debian box with Apache/php3 vs Apache/Jserv/BRL. PHP could beat BRL if BRL used Sun's JRE, but BRL beat PHP using IBM's JRE. When I switched from Apache/JServ to a Jetty server, BRL totally blew PHP away. I tried again when PHP4 made it into Debian, and surprisingly saw no significant difference.

    BRL's architecture is much like JSP, except BRL may be faster on the first request as it compiles a simpler language with no intermediate Java source. I would expect JSP to perform as well against PHP as BRL did, if not better.

  • by BubbaFett ( 47115 ) on Friday October 17, 2003 @12:31PM (#7240714)
    The article doesn't ignore horizontal scaling. It scales to over twice the width of my browser.
  • by TheLastUser ( 550621 ) on Friday October 17, 2003 @12:31PM (#7240720)
    You can make really big sites with PHP and you can make really big sites with Java, that's the fact. Each has advantages and disadvantages. Use what you want. Personally I use Java and while PHP lacks many facilities that Java has, Java also lacks things that PHP has. I would never look down on someone who uses PHP or any other language, because every language has trade offs. One thing that you get with PHP is a platform that is more tolerant of shitty code, when Java will blow, the PHP server will keep chugging along. With Java you have to use a more rigorous build and testing process, while with PHP you can deploy individual files here and there without too much worry. To me these sorts of consideration are as important, or even more important than distributed transactions, and session sharing. Not every site needs distributed transactions, or CMP or any of the other cool Java things. They are nice to have but they may not be required to make a specific site.
    • by poot_rootbeer ( 188613 ) on Friday October 17, 2003 @12:48PM (#7240899)
      One thing that you get with PHP is a platform that is more tolerant of shitty code, when Java will blow, the PHP server will keep chugging along.

      This is a Bad Thing.

      Shitty code doesn't belong in your application. If something fails because it's designed poorly, you NEED TO KNOW about it even if it results in
      an ugly fault message to your users.

      It's one of the fundamental tenets of programming: if you allow error conditions to go untrapped, things start getting secretly corrupted and you won't even notice it until it's too late to fix.
  • by yomahz ( 35486 ) on Friday October 17, 2003 @12:37PM (#7240768)
    There are a number of different aspects of scalability. It always starts with performance, which is what we will cover in this article. But it also covers issues such as code maintainability, fault tolerance, and the availability of programming staff.

    These are all reasonable issues, and should be covered whenever you are choosing the development platform for any large project. But in order to convey a convincing argument in this small space, I need to reduce the term scalability to its core concern: performance.


    I think he's chosen the shittiest option here. Sure, any technology will scale if you throw enough resources behind it. Just keep load balancing and you can make almost anything scale performance-wise.

    I think there are a lot of other factors that are much more important. Code maintenance, fault taulerance, etc. are much more important because those can't be fixed by throwing more hardware at it.

    J2EE application servers come with transactions, security, resource pooling, and concurrency right out of the box. That's a lot more than I can say for PHP.

    Now another thing... he's got his J2EE Architecture completely wrong when it comes to EJB's. With EJB 2.0 (which has been around since 2001), there is no RMI overhead for servlets communicating with Local EJBs. You'd only use a remote EJB if the bean resides on another server.
  • by b17bmbr ( 608864 ) on Friday October 17, 2003 @12:39PM (#7240795)
    apparently, the folks at JBOSS do think php scales as well as java [onjava.com]. of course they have a product to push, but they did use php and found it wouldn't hold up.
  • by penguin7of9 ( 697383 ) on Friday October 17, 2003 @12:44PM (#7240859)
    Computers are so fast that even very inefficient systems can easily saturate any network connection you could possibly have. All of Microsoft could probably be served from a single laptop by PHP or Java (not so sure about IIS/.NET--there are limits :-) if it was just a question of how quickly scripts get invoked and can pump out data.

    What makes web applications slow is database and file system access. So, no matter what language you use, you primarily have to worry about the scalability of your storage and database component.

    The major difference between PHP and Java is how they scale in terms of programming effort and complexity. PHP is great for projects of small to medium sized complexity, but not so good for anything really large. Java, on the other hand, is equally bad for everything: it's tedious to use for small projects and it's better than PHP for large projects, but that isn't saying much.
  • by Wolfier ( 94144 ) on Friday October 17, 2003 @12:45PM (#7240868)
    In a lot of applications horizontal scaling is much more important than vertical scaling.

    I cannot believe an article that talks about scalability simply just "ignores" horizontal scaling.
  • J2EE != EJB (Score:4, Informative)

    by shaper ( 88544 ) on Friday October 17, 2003 @12:46PM (#7240883) Homepage

    In the article, the author assumes that the J2EE application includes EJB's and from this assumption he builds in additional layers of overhead, especially with RMI calls to the EJB layer. His assumption is incorrect.

    If you really want performance in a J2EE app, you can stick to JSP's and servlets and limit the usage of EJB's. Still keep the presentation in the JSP layer and isolate the business logic in servlets. This approach is quite lean and scales hugely.

    When and how to use EJB's is just one part of J2EE application design.

  • by iamacat ( 583406 ) on Friday October 17, 2003 @12:54PM (#7240966)
    The problem is not Java's or PHP's scalability in terms of performance. If there is a problem, people write a better compiler, a better database, buy a faster server or buy more servers. Pocket change for web sites with millions of transactions per day.

    The problem is that Java, being a general-purpose, modern programming language, can be used to write understandable and secure code for very complex problems. And PHP, well, is not. Maybe you don't have an application that can be most cleanly implemented as a 5-tier architecture. But if you think you might in future, you don't want to start writting it in PHP. Not the logic portion at least.

    A lot of technologies - OO, EJB, relational data design - can seem useless and overcomplicated until one encounters a problem that is complicated. Maybe one of these days I will understand what inspires people to use XML, with schema and style sheets to communicate between their own client and server. Rather than using a nice binary RPC implementation, for example. But then maybe this is one example of a bad technology.

    On the other hand, you can still open database connections directly from JSP and combine ease of use of PHP with security of PHP. At least you can still call functions from your class library for connection pooling and input validation.
  • by temojen ( 678985 ) on Friday October 17, 2003 @01:01PM (#7241061) Journal
    I code PHP at work & Java Servlets at home. The reason I'm useing Servlets for my at home project is that I can leave a thread running in the background to do any database writes after the page is returned. It may not actually be any faster, but it sure seems that way to the user.
  • The PHP Scalability Myth
    The author should focus on PHP and what got improved there over the last years and not take an inocent other language into the dispute.

    Comparing PHP with Java is not like comparing Apples and Oranges, as both are fruits, but like comparing Cheese with Bread ... two only slightly related topics.

    What is Scalability?
    I dissagree with the author. Scaleability means: if I have a solution, and throw twice the problem (more requests, more data) on it, does it *only* need 100% more resources? Can I extend that by throwing 3 times, 4 times and so on the solution? Where is the point where the solution breaks? When I have it working on a problem ten times the original size? Or can it take 100 times the original size?

    Language and Database Performance
    Java performs as nice and well as a compiled language like C++. At least under Windows it beats both borland C++ and Visual C++, sometimes by a rather hughe factor. Hint: www.heise.de/ct latest articels about .Net/C# and Java/C++ performance.

    Database connectivity is not really an issue if you compare "languages".

    Comparing Architectures
    The way you define an architecture is not the problem in a PHP vs. Java comparision. In PHP you can not keep objects in memory between different web acesses. You have to save the context allways in the DB. In Java you could use a prevalent system, or files, and cash all objects in memory.

    The claimed RMI overhead in a Java N-Tier application only exists if you have each Tier on a different server. And then you have the SAME problem in PHP as well. The author points that out a bit late.

    Stateful and Stateless Architecture
    Nothing much to say here. IMHO an external session store is no real issue. The issue is keeping INTERNAL session state over several requests. To be able not to relly on the DB.

    The Convergence of Web Application Architecture
    I dont see the convergence. Where does PHP have something similar to container managed persistance for entity beans?
    Where does PHP have something similar to container managed transactions and container managed access rights and role managemnt on method level for clients interacting with session beans?
    Not at all.

    If PHP on top of Java is scalable, then why isn't PHP on top of C?
    Because PHP on C ... or PHP in a typical PHP engine, lacks the JVM :-) In a Servlet engine every request knows about all request made by the same session before. So all objects ever created by the same session reside side by side in memory until the session times out or they get removed.

    In PHP my previous requests need to know which requests likel will come later. And they have to prepare that by storing all relevant data further requests might need in a DB. Basicly: all PHP applications are only DB frontends used via the web. The simply contain only out of three kinds of statements: html formatting, sql select and sql update statements.

    True business logic is impossible in PHP ... as you can not reliable isolate parallel requests, except via the DB.

    You can hardly reuse PHP on the business logic level as you are far to strong tied to the DB you had in your initial design.

    You can not deploy "components" on different servers with differnt back ends and different configurations for the accessing front ends.

    Sure: there is a class of applications for which PHP perfectly suits. But the classes of applications for which Java suits and PHP not, is much bigger.

    PHP is only suiteable if you can write the application very monolitic. Java suits well when you can divide the Application up into individual components which get assembled and deployed later to form the application.

    Regards,
    angel'o'sphere

Nothing succeeds like success. -- Alexandre Dumas

Working...