Advanced PHP |
|
2024-11-26 |
|
|
37 |
|
|
So, we have determined we are cpu-bound and we need to go faster. What can we do?
Some low-hanging fruit:
include_path
include_path = "/usr/share/pear:."
<?php
include './template_helpers.inc';
include 'business_logic.inc';
?>
open_basedir
open_basedir = "/usr/share/htdocs/:/usr/share/pear/"
open_basedir checking adds some extra syscalls to every file operation. It can be useful,
but it is rather expensive, so turn it off if you don't think you need it.
variables_order
<?php
echo $_SERVER['DOCUMENT_ROOT'];
echo getenv('DOCUMENT_ROOT');
?>
If you never use cookies, turn those off too
Add an Opcode Cache
zend_extension=/usr/local/lib/php/20020429/apc.so
apc.enabled=1
apc.shm_segments=1
apc.optimization=0
apc.shm_size=30
apc.num_files_hint=10
apc.gc_ttl=10
apc.mmap_file_mask=/tmp/apc.XXXXXX
apc.filters=
Results
156 request/sec | Standard PHP 4.3 | |
161 requests/sec | Fix include_path, and only populate GP | |
191 requests/sec | Add IonCube Accelerator on top | |
196 requests/sec | APC no optimizer, IPC shared mem + semaphore locking | |
198 requests/sec | Turck MMCache no optimizer with spinlocks | |
200 requests/sec | APC no optimizer, mmap mem + user space sleep locks | |
202 requests/sec | Turck MMCache with optimizer and spinlocks | |