【发布时间】:2015-01-06 14:51:37
【问题描述】:
我正在开发一个使用 Python ndb 数据存储 API 的 Google 应用引擎应用程序。 由于我正在尝试优化应用程序,因此我想知道缓存数据而不是查询数据存储区,如此链接 http://blog.initlabs.com/post/16359268329/how-i-reduced-google-app-engine-costs-by-75 中所述。
据我所知,NDB 已经透明地使用了 memcache https://cloud.google.com/appengine/docs/python/ndb/
我看到大量的读取操作,但由于数据不经常更改,我不明白为什么。
在使用ndb的时候显式使用memcache没有意义吗?
更新
虽然我刷新了同一个页面,但我总是在 appstat 中看到类似的内容
@0ms memcache.Get real=6ms api=0ms cost=0 billed_ops=[]
@7ms datastore_v3.Get real=12ms api=0ms cost=0 billed_ops=[]
@22ms datastore_v3.RunQuery real=16ms api=0ms cost=0 billed_ops=[]
@41ms datastore_v3.RunQuery real=12ms api=0ms cost=0 billed_ops=[]
@92ms datastore_v3.RunQuery real=71ms api=0ms cost=0 billed_ops=[]
这让我觉得 memcache.Get(第一行)失败了。我对吗?怎么可能?
【问题讨论】:
-
您如何看待读取操作?这些的响应时间是多少?
-
我看到了百分比。我现在是唯一的用户,它在几个小时内达到 10%。无论如何,我正在引入 AppStats 以进行更好的测量
-
嗨,看看我的更新。谢谢
-
太棒了!你能分享引发该日志的代码吗?您是否明确调用过内存缓存?
标签: python google-app-engine google-cloud-datastore google-data-api