I'd never bothered to use an opcode cache before.
Sure, I had used accelerators that cached includes and stuff in ram, but
damn - APC has made my site (at least on dev machine) snappy.
It wasn't too bad before, but I make heavy use of the database.
This is necessary for me to make maintenance easier.
IE - my site deals with biology and latin names, and now that various
mtDNA tests are cheaper, there's a lot of taxonomy change going on.
First my beloved Hyla regilla changed to Pseudacris regilla, now (though
I disagree) it may be split with my species becoming Pseudacris sierra.
American Bullfrogs, Western Toads, several species are likely to have
changes to their taxonomy soon that I do agree with. So I have a unique
ID and every page where a species is mentioned, common/latin names are
grabbed from the DB so I can do a single SQL update and the entire site
is modern (and easily reverted too).
Anyway - I have a crap load of tables and a lot of queries per page, but
the results most queries almost never change. Caching the results with
APC has made things a lot faster.
But I even went beyond that. My site is all created via DOMDocument.
Most of the pages have a content div that rarely changes. Even though
caching the database sped it up, I found that on complex pages that used
a lot of calls to DOMDocument functions but rarely actually change,
creating the main content div as a separate dom object, exporting it to
an XML string and caching the XML string, and then importing the XML on
subsequent page loads sped them up as well.
I'm not done with the mods yet - there's a few places where poor code
design on my part makes it more difficult to do the separation of
content that can be cached, and I need to go to all of the sql
insert/update statements so the appropriate cached key/value pairs get
deleted upon successful insert, but damn - it makes a HUGE difference -
and I'm only doing opcode caching (APC breaks pear::MDB2). Once I figure
out how to tell it to cache includes EXCEPT for /usr/share/pear - I may
even squeak out more performance.
It's the 4th of July so lists are slow, so I just wanted to take my hat
off to the APC team. It absolutely rocks.
For others like me who just never bothered to look into it, look into it.
Only caveat - don't use it on shared hosting (maybe safe with php-cgi in
shared hosting), and don't call apc directly - call functions that wrap
apc so you can gracefully disable it (or even change to a different
opcode cache) - IE
function wrap_delete($key) {
$key = 'sherp_' . $key;
if (function_exists('apc_delete')) {
$value = apc_delete($key);
return $value;
} else {
return false;
}
}
function wrap_store($key,$value,$life=3600) {
$key = 'sherp_' . $key;
if (function_exists('apc_store')) {
$rs = apc_store($key,$value,$life);
return $rs;
} else {
return false;
}
}
(the sherp_ in above wrappers is just so that I don't have to worry
about collisions with other web apps I run that I port to apc. Kind of
like namespacing)
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php