Writing a high-preformance Web application

A question from comp.lang.php:

I’d rather know up-front what’s available to raise performance should I have the problem

The best thing you can do as a developer is come up with good data architecture, write efficient SQL and, to borrow a phrase from Yahoo’s Michael Radwin, “use abstraction sparingly”. Most bottlenecks in Web applications come from the database sever anyway… Beyond that, it’s basic programming: efficient memory use, fast algorithms, etc. Beyond that, it’s pure system administration: use a PHP accelerator, consider enabling query cache, make sure you have adequate memory on your system, fine-tune your database server, etc.

With application software already written and deployed, the only way to “raise performance” (especially in response to increasing loads) is to change the hardware architecture. First, you split the front end and the back end (i.e., you have a dedicated HTTP server and a dedicated database server, each properly configured for the task). Eventualy, the load may surpass the capacity of this architecture, and you will have to further transition to a server cluster (a layer of HTTP servers and a layer of database servers with load balancing all around).

So there’s no good real-life comparison available to compare those four solutions to write web applications? For instance, I’d be intested in hearing about business apps written in PHP in (CGI | FastCGI | mod_php) vs. Java as an application server.

CGI is patently inferior compared to both FastCGI and mod_php. On Apache, both FastCGI and mod_php work well. Most ISPs prefer mod_php, but Yahoo!, for one, likes FastCGI better (perhaps it has something to do with the fact that most ISPs run on Linux, whereas Yahoo! prefers FreeBSD). On Zeus, developers recommend FastCGI.

As to Java, it is not an application server; you can use it with different application servers (Tomcat, JBOSS, PowerTier, WebLogic, WebSphere, etc.) Those may have vastly different performance (and vastly different price tags).

Does it make a difference?

Here’s what Joel Spolsky once had to say on the subject:

the bottom line is that there are three and a half platforms (C#, Java, PHP, and a half Python) that are all equally likely to make you successful, an infinity of platforms where you’re pretty much guaranteed to fail spectacularly when it’s too late to change anything (Lisp, ISAPI DLLs written in C, Perl), and a handful of platforms where The Jury Is Not In, So Why Take The Risk When Your Job Is On The Line? (Ruby on Rails)… Python get a half because it’s on the border, about to cross the line from an “interesting” choice to a “safe” choice.

http://www.joelonsoftware.com/items/2006/09/01.html

If not, did all those companies choose Java because of the libraries?

No, because they had developers well-versed in Java and a nice round budget for big-ticket items such as WebLogic/WebSphere and Oracle. Companies that tried developing high-load Java applications on a low budget (as in Tomcat + MySQL) didn’t get very far; Friendster, for one, was plagued with performance problems so pervasive that they had to switch to PHP. There probably was an alternative, to switch from MySQL to Oracle and from Tomcat to a commercial application server, but they may have figured that the licenses are going to cost more than a complete rewrite of the front end…

What I’m driving at, is that I’d like to choose a technology based on real-life data

There is no real-life data. There is only anecdotal evidence. And you almost never know whether a particular project failed to meet the requirements because of the poor platform choice or because developers were inept, or because the planets were aligned unfavorably… Even people who worked on such projects often disagree as to the cause of failure; what can outsiders know for sure?

This entry was posted in Answers, Technology. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *