4

Memcache has been up and operational on my production site http://goniseko.com for a few months now. After getting everything configured and memory limits where they should be, I noticed that I have a very consistent 70% / 30% hit to miss ratio.

How can I improve this?

Also, I noticed that this is pretty consistent across other Drupal 7 sites where I have memcache installed.

What is it about Drupal, Memcache, or a combination of the two that won't allow for this extra 30% to be stored in the cache bins? How can I figure out what these queries are, and what can I do to get them in the bins?

I am hoping this is similar to APC. I have that configured so that I have a 100% hit rate for this site. I would like to have Memcache that high, or at least higher than 70%. That's almost 1 out of 3 queries that have to hit the db.

  • 2
    Is your cache big enough to hold everything it needs, or is the LRU algorithm kicking in? – mpdonadio Mar 29 '13 at 13:38
  • Nope, no evictions at all. Cache is set to 1 gig with it never having used more than 600MB. I have the memcache.php page setup, the one that looks / based on apc.php. It was protected with a default password. Is there harm in letting the general public see that? If not, I'm happy for people to take a look. – blue928 Mar 30 '13 at 4:39
  • have you enabled Block caching? Some blocks that force NO_CACHE for example will always hit the database, regardless of settings [Edit: i missed the date on this - if its still an issue, shout] – tobynew Dec 7 '16 at 16:10
1

I would interpret the numbers in a way that 70% of the traffic to your site are pages that are currently contained in the cache. The other 30% did go stale because the weren't visited frequently enough to stay fresh.

This is a more common problem about "How to cache?". The base Drupal cache is time based. If you don't use more complex methods like Drupal 8 tries to do for you there will always the problem that from time to time hits can't be cached. So probably 99% of you home page are cache hits. The 1% are the hits while the page is refresh. But any other page that is older than your settings on the "performance" settings page will be immediately stale. Means that if you cache for 5 minutes and the page is visited every 6 minutes it will never get a cache hit.

Your cache is currently more or less a protection against traffic spikes or (D)DOS attacks. But not something that really eases the web server in all occasions.

Real solutions for this go above this question and the easiest thing would be to go to Drupal 8. It really tries hard to cache your stuff for ever. http://buytaert.net/making-drupal-8-fly

All in all 70% is not that bad. You could try a module like boost: https://www.drupal.org/project/boost

And than find a way how to cache things until they are updated. But if you use a sidebar with views this will be a big problem if you don't go using asynchronous (AJAX / AHAH) calls by javascript or things like edge side includes (ESI)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.