How much memory is enough to allocate to memcache?

xamount - April 24, 2009 - 00:12
Project:Memcache API and Integration
Version:6.x-1.x-dev
Component:Documentation
Category:support request
Priority:normal
Assigned:Unassigned
Status:closed
Description

On the project page, it is stated: "If you use this file it is important to have enough memory allocated to memcache to store everything (including the page cache), otherwise the cache misses will negate the benefit of the cache hits."

How can I estimate whats a good average memory allocation size? (maybe the answer to this can be posted somehow on the project page?)

#1

jaydub - April 30, 2009 - 18:35

As I'm sure you suspect, there is no one size fits all recipe for how much memory to allocate. Of the various caches that memcache can serve, the page cache is the one that's most likely going to be the most variable. A large site with a lot of pages of course will want a larger memory allocation than a site with just a couple dozen pages.

I suggest you start by allocating more than you suspect you might in the end need. You can let some time pass on your server to see how filled up your memory gets and use that as a guide. If you have a testing server you could try to crawl your site to make sure that all your pages are hit so that you can see what your total page cache size ends up as a result.

#2

xamount - May 1, 2009 - 03:54

Thanks for your response. Understandably, there is no one size fits all. How can one determine the size of their page cache size though? Would I have to look at the cache table size in the database?

Also, my memcache status (using the stats provided in the memcache drupal module) shows

bytes 407.36 MB
hit_percentage 68.92%
mem_used 0.00%

The total memcache size allocated is 1GB. So the mem_used has always been 0% and this seems like conflicting data to me, so thats why I had originally created this issue.

#3

dropchew - May 3, 2009 - 05:27

subscribe, I had been allocating around the range of 64-256 per bin,

hit percentage is always around 80-90% mark but mem_used is always 0.00%, what does it mean actually? Allocated too much memory to bin?

#4

Jeremy - July 13, 2009 - 20:13
Status:active» fixed

There is no perfect amount of memory -- every website has different requirements. You can base your original tunings on your table sizes, but even this is really only a guesstimate. What's more important is that you monitor it after your initial setting and adjust as necessary. You can do so with the following basic rules:
1) If your evictions are increasing rapidly and your hit rate is lower than 90% or dropping, you should allocate more memory for your bin.
2) If your evictions are at 0 but your hit rate is still low, you should review your cache logic -- you're either flushing your cache too frequently, or you're caching data that isn't re-used enough to justify being cached.
3) If your evictions are 0 and your hit rate is higher than 90% and your bytes are significantly lower than the total RAM you allocated to this bin, you allocated more RAM than you needed to and can reduce the allocation.
4) Never allocate more memory than your server has! If your server starts swapping, performance will suffer greatly.

An optimal configuration will have your evictions at 0, your hit rate >90%, and enough allocated RAM to meet short term growth.

Answering your other question, mem_used is a broken stat, it tells you nothing.

#5

System Message - July 27, 2009 - 20:20
Status:fixed» closed

Automatically closed -- issue fixed for 2 weeks with no activity.

 
 

Drupal is a registered trademark of Dries Buytaert.