Slashdot Mirror


PHP Scales As Well As Java

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

23 of 627 comments (clear)

  1. What's the PHP equivalent to Java NIO? by Anonymous Coward · · Score: 2, Insightful

    And the other recent additions that add to the scalability of Java?

    1. Re:What's the PHP equivalent to Java NIO? by bigjocker · · Score: 3, Insightful

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

      --
      Life isn't like a box of chocolates. It's more like a jar of jalapenos. What you do today, might burn your ass tomorrow.
    2. Re:What's the PHP equivalent to Java NIO? by Waffle+Iron · · Score: 3, Insightful
      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.

  2. Scaling by stanmann · · Score: 2, Insightful

    Java and PHP Scale equally well... Well that isn't a big surprise since Java as I understand it doesn't scale very well..

    --
    Food not Bombs is a nice platitude but it breaks down when you notice that the Bombees are usually well fed
    1. Re:Scaling by Frymaster · · Score: 2, Insightful
      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!

  3. They scale differently by digidave · · Score: 4, Insightful

    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.

    --
    The global economy is a great thing until you feel it locally.
  4. IF you accept the underlying assumptions... by Dr.+Bent · · Score: 4, Insightful

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

  5. Oh, so that's why he said that... by DrEldarion · · Score: 2, Insightful

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

  6. where I stopped reading by BigGerman · · Score: 5, Insightful

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

  7. Re:Some facts by vlad_petric · · Score: 4, Insightful

    But connection pooling scales much, much better than persistent connections ... Especially when each user makes only a couple of requests.

    --

    The Raven

  8. Hrm by Etriaph · · Score: 4, Insightful
    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.

    --
    "It's here, but no one wants it." - The Sugar Speaker
  9. Apples to Oranges. by SatanicPuppy · · Score: 2, Insightful

    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.

    --
    ad logicam Claiming a proposition is false because it was presented as the conclusion of a fallacious argument.
  10. Re:Props to PHP by letxa2000 · · Score: 2, Insightful
    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.

  11. Re:of course it does... by stesch · · Score: 2, Insightful
    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.

  12. Re:Not exactly... [Re:Java owns PHP] by mark_lybarger · · Score: 2, Insightful

    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.

  13. strict/loose dynamic/static explicit/inferred by brlewis · · Score: 2, Insightful

    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.

  14. Re:of course it does... by Eric+Savage · · Score: 2, Insightful

    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.

    --

    This is not the greatest sig in the world, this is just a tribute.
  15. Re: Could someone explain instead of just flaming? by crazyphilman · · Score: 2, Insightful

    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.

    --
    Farewell! It's been a fine buncha years!
  16. Strict Typing by jbottero · · Score: 2, Insightful

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

  17. Re:Perl by pHDNgell · · Score: 2, Insightful

    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.

    --
    -- The world is watching America, and America is watching TV.
  18. Re:Here's why... by mikeg22 · · Score: 3, Insightful

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

  19. Re:Here's why... by Deacon+Jones · · Score: 2, Insightful
    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.

    --
    I pulled a jack move to cop this sig
  20. Re:What is your point? by SlightOverdose · · Score: 2, Insightful

    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!