#native_company# #native_desc#
#native_cta#

The Need For Speed

By Piergiorgio Spagnolatti
on March 21, 2001

One of the greatest advantages when using PHP is obviously speed. PHP4 is in general
fast enough for dynamic web content generation, and in most cases you can’t even think
of anything faster than it. But when you have to face lots of accesses, heavy applications,
narrow bandwidth, or other factors that can create performance bottlenecks, you may ask yourself
if you can do anything to make things work better. In this article I’ll explain what you can
do to further improve php performance, and how to make your users’ browsing experience even
more pleasant.

First of all, code optimization…

No, I’m not going to tell you again that you have to write clean and clear code, since
everyone knows it, and if you’re looking for speed then you probably already tweaked something
in your PHP sources. However, there’s something that can do this dirty job for you. It’s the
Zend Optimizer, available for free (you have to agree to the Zend Optimizer license, since it’s not
released under the GPL) from Zend Technologies
the people that brought us our blazing fast PHP engine). It “simply” goes over the intermediate code generated by
the Zend Engine and optimizes it for faster execution. I said “dirty job” since we all know
that tweaking code sometimes can bring you to unreadable code, and this is not what you want
to find when making changes to your nearly forgotten 3-years-old PHP application… 😉 .
You will notice that complex PHP sources sudden will benefit from Zend Optimizer, so I suggest
you to use it as long as it doesn’t produce strange incompatibilites with your code (never found one
though). Installing the Zend Optimizer is really easy. Just download the precompiled library
for your platform, add the following two lines in your php.ini, restart your webserver, and… That’s it!
zend_optimizer.optimization_level=15
zend_extension="/path/to/ZendOptimizer.so" 
zend_loader.enable=Off
Ooops… I said two lines and you find three. In fact the third line is optional, but it seems
that disabling this zend_loader speeds up a bit the Optimizer, so it’s worth a line in your php.ini.
Pay attention: you can disable the zend_loader only if you don’t use the Zend Encoder Runtime, which
will be discussed later.

1
|
2
|
3
|
4