views:

108

answers:

3

Memcache in general and on AppEngine in specific is unreliable in the sense that my data may be deleted from the cache for whatever reason at any point in time. However, in some cases there might be cases where a small risk may be worth the added performance using memcache could give, such as updating some data in memcache that gets saved periodically to some other, more reliable storage. Are there any numbers from Google that could give me an indication of the actual probability that a memcache entry would be lost from the cache before its expiration time, given that I keep within my quotas?

Are there any reasons other than hardware failure and administrative operations such as machines at the data centers being upgraded/moved/replaced that would cause entries to be removed from memcache prematurely?

+5  A: 

Memcache, like any cache, should be used as... a cache. If you can't find something in the cache, there must be a strategy to find it in permanent storage.

In addition to the reasons you mention, Memcache and other caching approaches have limits to the amount of items they will hold (discarding usually the least recently used ones when the cache is full), and often also set other cache invalidation policies (e.g. flush everything unused for one hour).

If you don't configure and operate the cache yourself, you have NO guarantee of when and how items might be removed from the cache intentionally / by design.

Eric J.
I appreciate that you're trying to help me avoid shooting myself in the foot by (ab)using Memcache as something other than a cache. However, what I'd really like to see are some statistics on how often I would lose data in practice, to make an informed decision about whether or not it would be worth the risk to keep some data in the cache only for some period of time.
Freed
@Freed: Statistics you may gather today could well not be valid tomorrow. Additionally, be cautious with any statistics you do gather because your sample size will be small and of unknown quality.
Eric J.
@Eric: ... which is exactly why I'm looking for more reliable data than just doing my own measurements. What I'd love to see is something along the line of the statistics that Google already provides for latency and throughput.
Freed
A: 

Any concrete answer you get to this question is 100% subject to change.

That said, I've used memcache under light loads to accumulate data for 15 minutes or so before writing it all to the Datastore. This was for totally non-critical analytic data though. Do not depend on it.

dkamins
+1  A: 

It's not that data can be lost, but that if it is lost, it can be easily regained.

For example, using it to store data from the datastore is ideal, in that if a piece of data is not in the cache, it can be easily fetched.
If you're storing data such as a hit counter in the cache, it can't be regained if the cache is cleared, so you'll lose data.

If you're concerned about load for a common job, how about setting a job to update the counter later, using the task queue?

Ink-Jet