Your Daily Source for Apache News and Information  
Breaking News Preferences Contribute Triggers Link Us Search About
Apache Today [Your Apache News Source] To

Apache HTTPD Links
Apache XML Project
The Apache FAQ
The Java Apache Project
The Jakarta Project
The Apache Software Foundation
Apache Project
Apache Module Registry
Apache-Related Projects
Apache-Perl Integration Project
PHP Server Side Scripting
The Linux Channel at
All Linux Devices
Apache Today
Linux Today
Linux Start
Linux Programming
Just Linux
Linux Planet
Enterprise Linux Today
BSD Central
Linux Apps
BSD Today
Linux Central
PHP 4.0 -- Dynamic Content for the World Wide Web Warrior
May 25, 2000, 18 :11 UTC (2 Talkback[s]) (5280 reads) (Other stories by Paul Ferris)

Editor, Apache Today

The world has changed overnight, in case you've blinked. The most change inducing technology affecting the planet right now is the Internet. Powering the Internet is a totally free product called Apache. The coolest web sites on the Internet are dynamic -- they change depending on what the viewer want to see, and that technology running on Apache can take the form of several things, but foremost among them is PHP technology from Zend corporation.

In case you came late to the PHP Party, don't worry -- there's plenty of reasons to celebrate. PHP is an open source server-side scripting language for creating dynamic web content, in place on some 2 million web sites worldwide -- and growing. There's a new version of PHP out, version 4.0. I just got around to downloading and giving it a whirl.

PHP 4.0 is not a trivial upgrade to an existing product -- it's a total re-write with backward compatibility to the 3.x technology. It's actually quite a feat, because they kept the compatibility with version 3.x, but made some radical changes under the hood. First and foremost, the 3.x product was really an interpreted language, each line of code was evaluated during the execution of the server side page.

With version 4.0, the functional difference is actually quite staggering -- the server actually compiles the code on the fly, and then executes the code, with dramatic improvements in speed as you can guess.

There's actually more to it than this. Zend technologies now provides an optimizer (not an open source product, by the way) for people who have created massive PHP projects and want to wring the most efficiency out of the system as possible.

As if that's not enough -- PHP has been separated completely from Apache, so that the language itself can be embedded into other products that need scripting languages. This is absolutely awesome news, as far as I'm concerned. Possibly even bigger news that PHP 4.0 itself.

I've come to enjoy coding in PHP a lot. I've found it's syntax is very consistent and it's ability to hide gory programming details to be extremely pleasant. I can only hope that the things that lack a good scripting language in open source projects will take this ball and run with it. Imagine all of your favorite databases running the same scripting language, one that's pretty easy to learn and fairly well documented. The possibilities are endless.


The Zend folks claim that PHP performance improvements in the new engine are orders of magnitude over PHP 3.x . I'm always skeptical of performance improvements (if you're reading Microsoft press releases of late, in regards to Windows 2000, you need to be extremely skeptical, but that's another story, alas).

I did some "benchmarking" of my own, with php3 and php4. I played with the Zend optimizer a bit, and ran the tests with it enabled and disabled. Using two identical PC's with 128 megs of RAM and similar software configurations, I loaded php4 and the exact same Linux Today index page (Linux Today and Apache Today both exclusively use php for everything web-oriented). I used the dubious "time" command to come up with the numbers that the user will experience under Mindcraft benchmark conditions.

No, I'm not being totally tongue-in-cheek here, I'm actually describing the real benchmark conditions. If you remember the Mindcraft benchmark conditions they had some seriously wide bandwidth pipes on a pretty fat server. What was different was that they requested static pages -- PHP provides dynamic content.

In other words, during my benchmark, I was the only person on my 100baseT network, requesting files from the only busy server on my network, at speeds that would be pretty much out of the price range of most people serving content on the world wide web. Even more to the point -- this isn't intended to be a "real" benchmark measuring conditions like you would experience under "real" load conditions. It's more intended to satisfy my curiosity as to whether the product actually would actually provided performance improvements for my application -- delivering the news.

Bear in mind that our application is not a huge one -- PHP can do far more complex things than make a dynamic news site. Our main page has multiple include files and an extremely small amount of database calls. It's been fairly optimized and trimmed down because some people poll it constantly looking for new Linux news.

I wouldn't know or pretend to understand who these people are (cough).

Anyway, at first glance the improvement was around 75% for an unoptimized (small) page. I know I'm happy with this, but it doesn't quite match up to the claims made by the Zend folks, and I kind of wanted to believe them in this case.

So I went searching for a real porker of (in comparison to the main page) a php3 page. It didn't take far to look, fortunately. Just about anything that Richard Stallman has ever written for Linux Today has resulting in an eruption of flame that makes anything I've ever touched upon look like a prayer session with the pope.

So, I chose the story:
UPDATED: Richard Stallman -- Boycott Amazon!
and proceeded to flog both servers with the url inserted in my hokey benchmark program. The result was similar -- about a 50-75 percent improvement in speed.

Then it hit me, yes, I was real-world testing -- everything in the equation. Not just php3/php4, but apache, my network, my browser -- everything.

In order to get a real grasp of how much better php4 was than php3, I should take a look at everything as compared to something that has php removed entirely -- something like a static page, for instance.

So, I dumped the file to a static html file, and tossed that into the mix. I think you'll find that the results are nothing short of staggering. Table one shows the results of three runs.

Quasi-Mind-Craft Benchmark Stats for PHP4 vs PHP3

RUN PHP3 Server
HTML static
PHP3 Server
PHP4 Server
HTML static
PHP4 Server
PHP4 Server
dynamic optimized
1 42.12 73.14 46.92 53.05 49.63
2 46.5 71.43 47.26 53.84 50.77
3 48.75 73.46 46.37 50.57 46.60
AVG 45.79 72.68 46.85 52.49 49.0
Figure 1

The benchmark runs were from identical hardware, each time represents the time for lynx to do a raw source dump 50 times for the Stallman article.

What should be immediately clear is that php4 shows a dramatic similarity (at least in my application) to static html files -- something I would never have expected at all. Our news_story page includes several fairly complex function files, some includes for content, and a portion of the main newswire, as well as an array of data from the main newswire. In other words, our story pages are kind of like a mini index page in and of themselves -- in addition to the story and talkback content.

The penalty for dynamic content using PHP version 4 in this rough benchmark was only 12 percent - and that's unoptimized as well. Optimized the penalty drops to an almost unbelievable 4.6 percent. In fact, some of the optimized php4 dynamic runs were faster than the static page runs. Clearly, this was a major surprise for me.

The penalty under version 3 for any dynamic content is by comparison 58 percent. I should state here that our pages are dynamic, but they do not use a database call for the content -- there is only one database call for user account preferences. Since a lot of dynamic content served by web sites is based upon some kind of SQL query, your mileage may vary. If enough people are curious, I'll do some exploration along these lines and publish the results.

I have to admit that at this point, I was pretty much blown away. The HTML file used in this example had no include files what-so-ever -- it was strictly one static file, and an good example of serving content at the fastest speed possible. For the curious, ad banners were not being served from remote locations, so all of the content was coming from my internal servers, and the site operation was at an identical configuration to the Linux Today's servers that are in-use. The static file size was 373062 bytes -- a real porker for a Linux Today story in my opinion.

Slicing and Dicing

Slicing the data another way, subtracting the static times from the dynamic times for each server, and comparing the results, the noticeable improvement on my end could be gauged at roughly 476% or over 4 and a half times faster for unoptimized pages. For optimized pages, the difference is a staggering 1250% or roughly 12 and a half times faster.

The claim by the Zend folks is that for complex scripts PHP 4 provides performance improvements in speed by a factor of anywhere between 5 and 200 times. I'd have to say that from my experiences, this isn't at all unrealistic.

Trials and Tribulations

I can only find good things to say about this upgrade. All of my existing code has worked without a hitch. When you factor in the speed improvement, it's like getting a free lunch.

I did have some small problems during installation, but it turned out that I wasn't reading the fine manual that they had included. I have an install script that worked with PHP version 3 that created a static httpd with the php3 module and mysql support, but I'll have to rewrite that now, I guess.

As for future improvements, there are some interesting things to consider. If you study how the Zend engine works, you'll find that it's compiling the code on the fly each time a page is accessed.

At ApacheCon this past year I met Zeev -- a terrific guy, I must add -- and after seeing the new PHP model, I asked him if the object code from page accesses was being cached (in other words, after the page gets compiled, does PHP save it so that the next time the page is accessed it won't have to do it again). The answer: not yet, but he knew of someone out there that was doing it, and it might eventually be included in the code.

Clearly there's another step here, and it doesn't stretch my imagination to see the product getting there. In the mean time, what an improvement. It would be incredibly cool if the next major upgrade to PHP provided some way to provide content at faster speeds than static files, wouldn't it?

I can only say that if you are planning a deployment using dynamic content, you would be seriously shooting yourself in the foot if chose any other technology. It's fast, the language is easy to learn, and it just plain makes the most economic sense. The web is growing and changing, and dynamic content web sites and web-based applications are the next big thing.

If this trend continues I'd say you should look for Zend technologies and PHP to play a huge role in this arena. Look for the product to improve even further. Look for the wave to go ever-increasing in the direction of open-source and the incredible power of the new Internet software development model.. Unlike the other choices available, this technology is here today and because of the open source nature of the product -- here to stay.

PHP 4:

PHP home page

The Zend Optimizer

Apache Home Page
Apache 1.3.12

Zeev Suraski: Under The Hood of PHP 4

  Current Newswire:
Netcraft Web Server Survey for December is available

O'Reilly: Apache Web-Serving with Mac OS X: Part 1

WDVL: Perl for Web Site Management: Part 3

Retro web application framework V1.1.0 release

Leveraging open standards such as Java, JSP, XML,J2EE, Expresso and Struts.

Netcraft Web Server Survey for November is available

FoxServ 2.0 Released

Ace's Hardware: Building a Better Webserver in the 21st Century

Web Techniques: Customer Number One

Apache-Frontpage RPM project updated

 Talkback(s) Name  Date
OK, I have read the PHP vs Perl article (obviously written prior to PHP 4.0) and ...   PHP 4.0 versus Perl & mod_perl   
  Jul 18, 2000, 01:53:52
I am a refugee from ASP and find PHP much the same, so it was a lot easier for m ...   Re: PHP 4.0 versus Perl & mod_perl   
  Aug 25, 2000, 18:48:44
Enter your comments below.
Your Name: Your Email Address:

Subject: CC: [will also send this talkback to an E-Mail address]

See our talkback-policy for or guidelines on talkback content.

About Triggers Media Kit Security Triggers Login

All times are recorded in UTC.
Linux is a trademark of Linus Torvalds.
Powered by Linux 2.4, Apache 1.3, and PHP 4
Copyright INT Media Group, Incorporated All Rights Reserved.
Legal Notices,  Licensing, Reprints, & Permissions,  Privacy Policy.