Without knowing more about your app, I can't say for sure, but it
seems likely that whatever processing takes place in "response.update
(object)" is using your cpu time, which is why you don't see much of a
speedup via caching here.  I would suggest profiling the operation to
determine what function call(s) are specifically taking the most
resources.  In my experience, you won't notice a large difference in
cpu usage between serializing model instances to memcache vs. adding
identifier information (like db keys) for fetching later.  My entities
are small, however, your mileage my vary.  I find that the primary
tradeoff in serializing large amounts of info to memcache is in
increased memory pressure and thus lower memcache hit rate, higher
datastore access.

On Jun 22, 12:48 pm, John Tantalo <[email protected]> wrote:
> I recently attempted to improve the responsiveness of one of my app's
> more elementary handlers by using memcache to cache the datastore
> lookups. According to my logs, this has had a positive effect on my
> api_cpu_ms, reducing this time to 72 ms. However, the cpu_ms has not
> seen a similar decrease, and hovers around 1000ms.
>
> Do memcache gets count towards api_cpu_ms or cpu_ms? Do I need to
> worry about performance issues around deserializing model instances in
> memcache?
>
> My caching strategy looks like this:
>
> response = dict() # (might not be empty)
> cached = memcache.get(__CACHE_KEY)
> if cached:
>   response.update(cached)
>   return
> else:
>   # datastore calls
>   foo = get_foo()
>   bar = get_bar()
>   # build cache object
>   cached = dict(foo=foo, edits=bar)
>   response.update(cached)
>   # cache
>   memcache.set(__CACHE_KEY, cached)
>   return
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to