-->

GAE Memcache Usage for NDB Seems Low

2020-07-24 05:13发布

问题:

I have a Google App Engine project with a ~40 GB database, and I'm getting poor read performance with NDB. I've noticed that my memcache size (as listed on the dashboard) is only about 2 MB. I would expect NDB to implicitly make more use of memcache to improve performance.

Is there a way of debugging NDB's memcache usage?

回答1:

The question is rather poorly formulated -- there are a zillion reasons for poor read performance, and most are due to a poorly written app, but you don't tell us anything about the app.

The only question that can be answered is the final one: "Is there a way of debugging NDB's memcache usage?" In addition to Sologoub's pointers I'd suggest using Appstats to find out whether the expected memcache calls are actually being made. And reading the NDB source code, especially get() and put() in context.py, might also help.



回答2:

This page does a good job explaining how NDB caching works: https://developers.google.com/appengine/docs/python/ndb/cache

The first place I'd check would be the policy settings to make sure that you are in fact telling NDB to cache what you want cached: https://developers.google.com/appengine/docs/python/ndb/cache#policy_functions