38 Comments
- djg38, on 10/11/2007, -0/+21If we're talking performance, ASP's proven to scale, where RoR hasn't yet. It may, but there's no MySpace-scale sites running on that to *really* know.
I honestly found this article rather useless. It only skims over a couple topics and gives some poor advice (enabling compression doesn't belong in an article called "Optimizing Apache and PHP" since it REDUCES performance -- this isn't about reducing bandwidth at the expense of higher CPU load). Buried as inaccurate and lame. - traphik, on 10/11/2007, -6/+25Yea, cause Ruby on Rails is a programming language that can compare to PHP...
It's sarcasm for those who can't tell - fuzzmeister, on 10/11/2007, -8/+22RoR, sure. ASP... no. No proprietary for me, thanks.
- markdr123, on 10/11/2007, -1/+15Oh shut up, PHP is great.
- syafthegeek, on 10/11/2007, -3/+15PHP rocks! I love PHP because of its performance and I hate Java because it is so damn slow.
- djg38, on 10/11/2007, -0/+8LightHTTPd is great for serving static content, not so great where Apache's modular design allows such extensibility. They make an awesome pair when you have the static content served by LightHTTPd and the dynamic parts served by Apache on the same box.
- vroom101, on 10/11/2007, -0/+8Tuning LAMP systems, Part 1: Understanding the LAMP architecture
http://www.ibm.com/developerworks/linux/library/l-tune-lamp-1/ - djg38, on 10/11/2007, -1/+6Unless your code is trying to find a solution to the travelling salesman problem on a million-node graph using a brute force algorithm, a single database connect and query will take longer than the entire execution of the PHP code. Realistically all you need to do for most web apps as far as PHP speed is run a byte-code cache like APC or eAccelerator. I see 99.99% cache hits on http://www.w3counter.com; the Symfony framework, which consists of over 2,000 PHP files, has a total runtime overhead of less than 25 milliseconds in real practice. The time to connect and run a constant time query (like "SELECT 'hello'") is longer than that.
- inactive, on 10/11/2007, -0/+5"They make an awesome pair when you have the static content served by LightHTTPd and the dynamic parts served by Apache on the same box."
Now I'D like to see a tutorial on that! - darkhero, on 10/11/2007, -1/+6"ASP's proven to scale, where RoR hasn't yet."
Very True. RoR = quick and dirty. It is very quick to make something. But harder to make it something bigger. Myspace also announced a while back that they were switching to ASP from Coldfusion. - inactive, on 10/11/2007, -2/+5The first thing to do is optimize your PHP code. Caching is one way, but nothing beats actual optimization, whether via C or by simply better code. The processing power needed for PHP scripts will grind your server into the ground way before Override settings in Apache will start showing a noticeable performance benefit. Take a look at the Wordpress sites that digg takes down so often. The PHP code is simply too taxing. You must cache and write better code...only then should you look at other methods of optimization.
- etnu, on 10/11/2007, -1/+4You people have no idea what you're talking about.
The HTTP model of page generation espoused by PHP advocates works equally well in RoR or ASP (or Python, or really any language). ultimately, it's the CGI model, and the CGI model is proven to scale.
Essentially, what you have is a very large number of http servers, and those http servers run processes that isolated from one another.
You run into scaling problems when it comes to things like resource access. Making a database scale is a lot harder than a web server. - thushan, on 10/11/2007, -1/+3Bottom Line: You should use the right tool for the right job.
Java web apps (thinking J2EE here) is suited for enterprise development (big teams, big companies, big money).
PHP, Unix host, fairly big but not enterprise level. alternative to ASP.NET on IIS.
ASP.NET (forgetting mono here) if your company is deploying on IIS or a primarily microsoft development environment.
RoR/Django if your after a quick turn around without messing with a gazilion config files.
Perl, well I've used that so long ago I've forgotten most of it. Kudos for Matt Wright for getting me into it back in the days!
This is just my opinion, I started out with Classic-ASP and PHP3 back in the days. flame away if you think otherwise:-) - Hedegaard, on 10/11/2007, -0/+2darkhero - why bring Coldfusion into this ? That language has been dead for a long time now. Even Macromedia (now Adobe) has realized this.
- strangewill, on 10/11/2007, -4/+6ASP.NET is nice, I like writing stuff in C#, but the language is very constricted in how you're suppose to build and run web applications, it really does bother me being as most of the web engine is already there including HOW a page is constructed, it bothers me and doesn't allow me to expand from the ground up like I'd like. (at least without going against how ASP.NET is suppose to run)
I started out in ASP myself (VBScript), I enjoyed it, got lots of projects going at work, a fully functional database system for a fitness center, but once I went OOP and wanted to develop software that everyone could use, I went PHP. It's a good place to start, and now Linux platforms can support it (though I've run into minor include errors when I first tried that, hope they fixed those)
Now if only PHP 4 was still "standard" isn't that like 7 years old? We should be like 99% PHP 5 by now... PHP 6 is in the works, and probably wont be standard for another decade. Fun. (PHP's downfall in my opinion), that and stupid things like Magic Quotes.
As for scalability, I'm kind of saddened that PHP doesn't support it much, I've built a base engine that hopefully will allow me to scale easily and load balance sites, but it seems that PHP could perform better. I hope it does in PHP 6.
Each of them how their pros and cons, ASP.NET being constricted and needing IIS. ASP for being outdated and lacking OOP structures. PHP for being way outdated (community's fault, not developers) and scalability problems. - alienvenom, on 10/11/2007, -0/+2Bitch please.
People are still using apache? Why not give lighttpd + php/fastcgi a try? On my server, with a finely-tuned apache I was seeing load averages of about 3 or 4 without 1000 req/s. With lighttpd + php/fastcgi, I see load averages < 1!
Also, lighttpd supports all sorts of C-style cacheing mechanisms as well should you want even better performance. - HarryHunt, on 10/11/2007, -0/+2@etnu: The CGI model has proven to scale? Yeah, right. That's also why as soon as other options were available, everybody switched to mod_perl, mod_php or ISAPI on IIS
CGI might scale to a certain degree, but it wastes a ton of resources. The only reason why it's still in use is because its very easy to program for. - inkubux, on 10/11/2007, -0/+2Use a pre-cache compiler like APC.
Use caching wisely
Reduce the number of sql query (through caching)
Reduce the number data transfered to the user
Use a squid proxy in front of your apache - srg13, on 10/11/2007, -0/+2Yeah, I couldn't live without all my apache modules...
- etnu, on 10/11/2007, -1/+2Instruction for instruction, PHP instructions are processed slower than java instructions under the good implementations.
This is absolutely true. There are reams of benchmarks to prove it, even. Implementing quicksort in PHP is going to be tremendously slower than doing it in Java.
HOWEVER
The majority of PHP code is NOT performed this way! Almost all PHP execution takes place in extensions, which are actually written in C.
PHP is not a general purpose programming language. It was never intended to be, nor will it ever evolve into one.
In practice, PHP applications actually perform better than Java applications for most of the common uses of the web. Virtually every page works something like:
- Receive user input
- Process
- Query "database"
- Format output
- Send to browser
You'll notice here that we're not doing anything complicated here. Under the covers, PHP relies heavily on some reasonably well-implemented algorithms and data structures to do most of the dirty work (fundamentally, everything is a hash table). This is transparent to the PHP programmer. - codenexus, on 10/11/2007, -0/+1Yeah use a better and more popular language like ASP.... oh hang on... heh PHP is more popular.
Also, how exactly is one language "better" than another anyway?! Its like saying English is better than Spanish or Cantonese or something. Just crazy talk I say! - etnu, on 10/11/2007, -2/+3You have no idea what you're talking about, either.
Typical PHP applications spend more time in the compiler than in the executor. Most of the heavy lifting in "PHP" apps is actually done by the database or some middle tier service.
You shouldn't be implementing complex algorithms in PHP. Most of the stuff you'll need is already implemented for you, anyway, and the few things that aren't can be done in C as extensions.
However, there are plenty of cases where people do things naively in PHP simply because they don't know how the language works.
Classic example:
for($i = 0, $j = count($items); $i < $j; ++$i){doSomethingWith($items[i]);}
vs.
foreach($items as $item){doSomethingWith($items);}
In classic CS education languages (C, Java), the former should be faster. The way that things are actually implemented in PHP, the second will always win. - thushan, on 10/11/2007, -0/+1wait till you try J2EE development... (JSF+JAAS+EJBs)
Add Netbeans as your development environment and you'll be ***** Beans for weeks! WebService WSDL's cant be generated if Transfer Objects (TOs) arent local to the EJB, JAAS can kiss my ASS with all the hoops we've had to jump through to get that to work properly with webservices & method level " authentication / authorisation", constantly redeploying web-apps even after minor changes, oh god then there's Sun Application Server 9. Tomcat's *much* better especially with JRE6.
All your JSP pages get converted into java code (do "View Servlet" in Netbeans on a JSP page) and you'll see its converting the standard HTML output to the ResponseWriter's output buffer.
Java has improved greatly from the 1.3/1.4 days. Dont assume its slow because everyone says its slow.
If you want quick n Dirty, try RoR or DJango (Python) if the current PHP, ASP.NET are too much work for you, DJango's quite nice and funky. Unless you *really* want to be Beaning around and have lots of developers stay away from J2EE. Banks/big corporations/projects can make use of the "Enterprise Level" development.
And yes this is a rant on J2EE even though there's no mention of it anywhere. But it had to be said. - etnu, on 10/11/2007, -1/+1The "LAMP" architecture wins hands down for web content under virtually all circumstances. Java can be used in the "LAMP" stack, because the term has really evolved to mean any http-based service supported by back end infrastructure.
HTTP front end written in JSP -> connects to Java application servers, oracle, or other back end -> outputs html
This works reasonably well.
Of course, JSP is a giant piece of ***** compared to PHP, Perl, Ruby, or Python (mostly for the same reasons that servlets are a giant piece of *****), so you'll still want to use one of those languages for the front end. The back end could be Java (and it frequently is, nothing wrong with it). - kevmaster, on 10/10/2007, -0/+0How I managed to easily survive 2 frontpage diggs at the same time. An in depth article.
http://digg.com/linux_unix/How_to_easily_survive_the_Digg_effect - HarryHunt, on 10/11/2007, -7/+7Why is that every time somebody mentions a technology, somebody else has to say something along the lines of "Or you could just use X which is much better"
"Windows Vista was just released" "Oh yeah, use Linux"
"Some company just found a cure for HIV and cancer" "Oh yeah, you should use Ruby on Rails instead"
Seriously: stop that! Nobody cares about what you like! - AntonShevchuk, on 10/11/2007, -0/+0More time spent with operation with database.
Optimize your PHP application architecture for decrease SQL queries
P.S. Use Zend Optimizer (http://www.zend.com/products/zend_optimizer) for optimize LAMP - nite23, on 10/11/2007, -3/+2StrangeWill is right... native Tomcat on JRE6 is pretty fast...
- Terr01, on 10/11/2007, -2/+1@etnu: Are you sure you're not conflating JSP with, say, J2EE JavaBeans? JSP itself does pretty much what PHP does--it's a preprocessor so you can write content with instructions inside it, rather than instructions with humungously big print statements.
- Ngai, on 10/11/2007, -3/+1Burying as inaccurate and lame is erroneous.
- HarryHunt, on 10/11/2007, -2/+0Let's see: PHP is interpreted, Java has a JIT-compiler that produces machine code. Java has a generational garbage collector and does heap allocation with stack-speed, PHP probably has a mark-and-sweep garbage collector...
Java being slow is a myth from when it was still bytecode interpreted. It's true that for a Java app to run fast, you need a fast machine to begin with, but Java's execution speed is way better than that of PHP, even with caching enabled.
If the last time you tried Java was in 1995, you should know that a lot has changed since then... - strangewill, on 10/11/2007, -9/+3Sure you didn't get that backwards? At least compiled Java applications seem to be MUCH faster than their PHP counterparts (though I haven't written JSP pages)
- nite23, on 10/11/2007, -7/+1LAMP is for kids, if you want performance and security, use Java and PostgreSQL ...
- jeet404, on 10/11/2007, -8/+1rarrrrrrrrrrrrrrr
- inactive, on 10/11/2007, -8/+1I don't like ASP.NET, but I wouldn't suggest that PHP isn't proprietary. How could it not be?
- m1th, on 10/11/2007, -8/+1Lighthttpd > Apache.
- DanielMartin, on 10/11/2007, -42/+1Or use something better, ASP.NET or Ruby on Rails.


What is Digg?
The Digg Toolbar for Firefox lets you Digg, submit content, and keep track of Digg even when you're not on the Digg site. Download the official