I just can't figure it out, where my configuration goes wrong, since I get so many misses and so few hits. And eventually that causes memory leaks.
See yourself. Notice that I'm using APCu rather than APC.
http://i.stack.imgur.com/3DPxo.png
Do you have any ideas of what I might be doing wrong, or what goes wrong?
Yes, I am aware of the following question and answer: APC Hits/Misses and configuration. Yet, after many tries of tweaking configuration, I can't still understand why so many misses.
I have a simple meta search app, where all the results from searches, are cached with APC. The following code, is a demonstration of how I process such data.
$dynamic_variable = "query_{$query}_page$this->page"; // This is just one case of many.
// Get Data from Cache
$cache_variable = "api1_{$dynamic_variable}_cached";
$result = $this->cache->get($cache_variable);
if ( ! $result) {
$result = .....
$this->cache->save($cache_variable, $result, $this->cache_timeout);
}
return $result;
And just to mention it, the app is currently using CodeIgniter 2.1.4, and migrating to https://github.com/ellislab/codeigniter/tree/release/3.0.
In the screenshot, the server is reporting that it has only been up for 8 minutes - that's hardly enough time to get a stable picture.
Try checking the numbers after it has been handling a realistic volume of traffic.
update
Since posting the answer above the image was updated from this to this - yes, in the updated image the hit rate is abnormally low. The answer lies somewhere in your code or how people are using the site - not in APC.
A slam defence of 1 doesn't make much sense.
I suspect if you test this with a known set of the requests you'll find it will yeild a predictable hit rate. What are you storing? If you're using sessions, it's likely a fault in your code (e.g. calling session_start() after headers sent).