如何使用 Google App Engine 中的 put() 将超过 500 个条目添加到数据存储区?
我尝试通过几次调用 db.put() 在列表中添加批量数据。但还是偶尔会超时。
有人有一些建议吗?
I tried adding batches of data in a list with a couple of calls to db.put(). But it still timeouts occasionally.
Anyone have some tips?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果遇到超时,请使用多个 put,并使用较小的批量大小(例如,将其减半)。不过,如果您在一个用户请求中添加 500 多个实体,那么您可能做错了什么。
Use multiple puts, and use smaller batch sizes (halving them, for example) if you encounter timeouts. If you're adding 500+ entities in one user request, though, you're probably doing something wrong, though.
Google 随 App Engine 提供的批量加载客户端 (bulkload_client 源)默认批量大小为 10,所以这告诉我你必须非常小心批量的大小。
我最近删除了数千个对象,发现最多可以传递给 db.delete() 的对象约为 400 个。但是,有时会超时,我会下降到 350 个。我不确定删除或放置是否有效不过更贵。
The bulkload client that Google provides with App Engine (bulkload_client source) defaults batch size to 10, so that tells me that you have to very careful about the size of your batches.
I was recently deleting several thousand objects and found that the most I could pass to db.delete() was around 400. But, sometimes that would timeout and I'd go down to 350. I'm not sure if deletes or puts are more expensive though.