Google App Engine: Is adding to the task queue faster than doing a datastore write?

匿名 (未验证) 提交于 2019-12-03 08:59:04

问题:

I'm trying to optimize some of the user facing parts of my app by adding background tasks to the task queue rather than performing the operations right away. For CPU intensive tasks it's an obvious choice to do it this way, but what about for simply saving data?

Is it faster on average to perform a taskqueue.add() operation or a db.put() operation, or is it about the same?

回答1:

Yes, marginally. Task queue payloads are limited to 10kb, though, and the performance difference is small enough you shouldn't use a task queue task just to store a datastore record. If you're concerned about datastore latency, look into the async API or Guido's NDB project so you can continue to do other work while you wait for the put to finish.



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!