Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does memcached share across servers in google app engine?

On the memcached website it says that memcached is a distributed memory cache. It implies that it can run across multiple servers and maintain some sort of consistency. When I make a request in google app engine, there is a high probability that request in the same entity group will be serviced by the same server.

My question is, say there were two servers servicing my request, is the view of memcached from these two servers the same? That is, do things I put in memcached in one server reflected in the memcached instance for the other server, or are these two completely separate memcached instances (one for each server)?

Specifically, I want each server to actually run its own instance of memcached (no replication in other memcached instances). If it is the case that these two memcached instances update one another concerning changes made to them, is there a way to disable this?

I apologize if these questions are stupid, as I just started reading about it, but these are initial questions I have run into. Thanks.

like image 292
Stephen Cagle Avatar asked Aug 09 '09 21:08

Stephen Cagle


3 Answers

App Engine does not really use memcached, but rather an API-compatible reimplementation (chiefly by the same guy, I believe -- in his "20% time";-).

Cached values may disappear at any time (via explicit expiration, a crash in one server, or due to memory scarcity in which case they're evicted in least-recently-used order, etc), but if they don't disappear they are consistent when viewed by different servers.

like image 75
Alex Martelli Avatar answered Oct 19 '22 07:10

Alex Martelli


The memcached server chosen doesn't depend on the entity group that you're using (the entity group is a concept from the datastore, a different beast).

Each server runs its own instance of memcached, and each server will store a percentage of the objects that you store in memcache. The way it works is that when you use the memcached API to store something under a given key, a memcached server is chosen (based on the key).

There is no replication between memcached instances, if one of those boxes goes down, you lose 1/N of your memcached' data (N being the number of memcached instances running in AppEngine).

like image 4
Joaquin Cuenca Abela Avatar answered Oct 19 '22 07:10

Joaquin Cuenca Abela


Typically, memcached does not share data between servers. The application server hashes the key to choose a memcached server, and then communicates with that server to get or set the data.

like image 2
Ned Batchelder Avatar answered Oct 19 '22 07:10

Ned Batchelder