PHP Tuning Tips
- The bottle neck for PHP scripts is the CPU unlike HTML pages. So get the fastest CPU you can afford.
If your going to be doing static HTML files try to get as much ram as you can afford.
- Enable HTML compression with ob_gzhandler().
This function is designed to check the Content-Encoding header for deflate or gzip,
and automatically compresses the output using the supported encoding. Using it is as simple
as turning output buffering on, and setting it as the output handler function: ob_start("ob_gzhandler");
or in the php.ini file with the line: output_handler = ob_gzhandler;.You might want to test this first using ob_start to see if it helps
with the download time on larger text output. Also only use this on PHP version 4.1.0 or above and you will need zlib support compiled in to PHP.
gzip'ed output is supported by IE 4.0 and higher, Netscape 4.x and Mozilla.
- Use PHP caching software to speed up your scripts.These cache the PHP scripts so they don't have to be compiled everytime they are executed.
Some examples of this software are: PHP Accelerator,Zend Accelerator,Afterburner Cache, and APC. I've read PHP Accelerator is the best.Most will give a 25-100% improvement
- Use version 2.0 of apache if you can and compile PHP into it. Apache 2.0 uses threads and improves speed.
- Switch from file based sessions to shared memory sessions. Compile PHP with the --with-mm option and set session.save_handler=mm in php.ini.
Use this feature on PHP 4.2.0 or above.
- Use output buffering via the ob_start() function. This may speed up your PHP code by 5-15% if you like to use print or echo statements in your code.
If your already using ob_gzhandler (mentioned above) as a function or as a output handler then you don't need to use ob_start because it's already being used.
- The PHP development team recommends compiling PHP4 with the following settings