Datasheet

12
Part I PHP: The Basics
Stability
The word stable means two different things in this context:
The server doesn’t need to be rebooted often.
The software doesn’t change radically and incompatibly from release to release.
To our advantage, both of these connotations apply to both MySQL and PHP.
Apache Server is generally considered the most stable of major Web servers, with a reputation
for enviable uptime percentages. Although it is not the fastest nor the easiest to administer,
once you get it set up, Apache HTTP Server seemingly never crashes. It also doesn’t require
server reboots every time a setting is changed (at least on the Unix side). PHP inherits this
reliability; plus, its own implementation is solid yet lightweight. In a two-and-a-half-month
head-to-head test conducted by the Network Computing labs in October 1999, Apache Server
with PHP handily beat both IIS/Visual Studio and Netscape Enterprise Server/Java for stability
of environment.
PHP and MySQL are also both stable in the sense of feature stability. Their respective develop-
ment teams have thus far enjoyed a clear vision of their project and refused to be distracted
by every new fad and ill-thought-out user demand that comes along. Much of the effort goes
into incremental performance improvements, communicating with more major databases, or
adding better session support. In the case of MySQL, the addition of reasonable and expected
new features has hit a rapid clip. For both PHP and MySQL, such improvements have rarely
come at the expense of compatibility. Applications written in PHP3 will function with little or
no revision for PHP4 and 5. And because of the standards-based SQL support, MySQL 3.x
databases are easily moved to more current versions (and most likely always will be).
Speed
PHP is pleasingly zippy in its execution, especially when compiled as an Apache module on
the Unix side. The MySQL server, once started, executes even very complex queries with
huge result sets in record-setting time.
PHP5 is much faster for almost every use than CGI scripts. There is an unfortunate grain of
truth to the joke that CGI stands for “Can’t Go Instantly.” Although many CGI scripts are writ-
ten in C, one of the lowest-level and therefore speediest of the major programming languages,
they are hindered by the fact that each request must spawn an entirely new process after
being handed off from the
http daemon. The time and resources necessary for this handoff
and spawning are considerable, and there can be limits to the number of concurrent pro-
cesses that can be running at any one time. Other CGI scripting languages such as Perl and
Tcl can be quite slow. Most Web sites have moved away from use of CGI for performance and
security reasons.
Although it takes a slight performance hit by being interpreted rather than compiled, this is
far outweighed by the benefits PHP derives from its status as a Web server module. When
compiled this way, PHP becomes part of the
http daemon itself. Because there is no transfer
to and from a separate application server (as there is with ColdFusion, for instance) requests
can be filled with maximum efficiency.
Although no extensive formal benchmarks have compared the two, much anecdotal evidence
and many small benchmarks suggest that PHP is at least as fast as ASP and readily outperforms
ColdFusion or JSP in most applications.
03 557467 ch01.qxd 4/5/04 11:06 AM Page 12