views:

86

answers:

1

I have created an app using GAE. I am expecting 100k request daily. At present for each request app need to lookup 4 tables and 8 diff columns before performing needed task.

These 4 tables are my master tables having 5k,500, 200 and 30 records. It is under 1 MB (The limit).

Now I want to put my master records in memcache for faster access and reduce RPC call. When any user update master i'll replace the memcache object.

I need community suggestion about this.

Is it OK to change the current design?

How can i put 4 master table data in memcache?

Here is how application works currently

  1. 100 of users access same application page.
  2. They provide a unique identification token and 3 more parameters (lets say p1,p2 and p3).
  3. My servlet recieve the request.
  4. Application Fetch User Table by token and and check enable state.
  5. Application fetch another table (say departmment) and check p1 existance. If exists check enable status.
  6. If above return true, a service table is quried based on parameter p2 to check whether this service is enabled or not for this user and check Service EndDate.
  7. Based on p3 length another table is checked for availability.
+3  A: 

You shouldn't be thinking in terms of inserting tables into memcache. Instead, use an 'optimistic cache' strategy: any time you need to perform an operation that you want to cache, first attempt to look it up in memcache, and if that fails, fetch it from the datastore, then store in memcache. Here's an example:

def cached_get(key):
  entity = memcache.get(str(key))
  if not entity:
    entity = db.get(key)
    memcache.set(str(key), entity)
  return entity

Note, though, that caching individual entities is fairly low return - the datastore is fairly fast at doing fetches. Caching query results or rendered pages will give a much better improvement in speed.

Nick Johnson
My problem is still there. I want to resduce RPCs.
Manjoor
You're going to have to be more specific about what your problem is, and what was wrong with my answer, if you want anyone to be able to help.
Nick Johnson
Manjoor: Reducing RPCs is a good idea, but you have to get your data from somewhere. Also, not all RPCs cost the same - memcache gets should typically only have a few milliseconds of overhead. Datastore RPC latency is often quite a bit higher (~100x).
David Underhill