There are a number of accelerator / compiler projects around, some of which are free. However, few of them work properly with PHP 5.1.3 (i.e. unreleased) yet.
I tried using APC a while back (the only "official" one as far as I know), but its behaviour is peculiar- it doesn't seem to do much and it crashes the CLI on exit (even if disabled at the time).
Anyway, apparently "eAccelerator" is the one to use.
I did some informal benchmarks here on Linux / Apache / PHP 5.1.3, here are some results:
A typical page generation time without eaccelerator - 80 milliseconds
With eaccelerator - 16 milliseconds.
This particular page doesn't do very much database access (probably only a couple of queries) but does use Smarty to generate the HTML.
Anyway, it's a good performance increase.
The process was repeated several times. Of course your mileage may vary.
My recommendations for anyone wanting to benchmark a PHP application page generation:
- Use Apache to time the request time - it's not difficult
- Do it on an otherwise idle machine - specifically, don't run the web browser on the same machine, otherwise you're timing your web browser's speed too. The web browser and server can fight for CPU causing detrimental performance.
- Repeat the process a lot of times and discard outlying values.
Mark