Niklas Rosencrantz
Niklas Rosencrantz

Reputation: 26652

How can I increase my memcache hit ratio?

For my appengine app my memcache hit ratio is only 40 % and I use it extensively. Can I use appstats to profile my app to see why I don't get better hit rate? What would be a strategy to increase hit rate? Will hit rate rise when the app is used more? Can I profile my app more if I use some more performance profiling tool? Should I increase or decrease the number of items in memcache?

enter image description here

Upvotes: 2

Views: 791

Answers (1)

Brent Washburne
Brent Washburne

Reputation: 13138

It sounds like 60% of your cache requests are one-time misses, while 40% are multiple requests for the same items. That's not too bad for something like Facebook, with billion-item databases.

Take a look at the cache requests and see if you can prime the cache with a lot of those items. That is, load the cache with the most popular items so that subsequent request for them are hits.

If there is any connection between the items, you might want to add the related items to the cache. For example, if a request for item A is followed by requests for items A1 and A2, then you could load all three items into the cache on the first request. This could be called "smart priming".

In general, the strategy is to predict what is going to be requested and to prime the cache with those items. Your data is in the request logs.

Upvotes: 3

Related Questions