AppEngine Query.fetch_async not very asynchronous?

后端 未结 2 1551
温柔的废话
温柔的废话 2020-12-09 06:57

I\'m trying to reduce the execution time of an AppEngine query by running multiple sub-queries asynchronously, using query.fetch_async(). However, it seems that the gain is

相关标签:
2条回答
  • 2020-12-09 07:31

    Are you always running run_parallel before run_serial? If so ndb caches the results and is able to pull the information much faster. Try flipping the results or even better try with DB, as ndb is just a wrapper to include memcache results.

    0 讨论(0)
  • 2020-12-09 07:33

    The main problem is that your example is mostly CPU-bound as opposed to IO-bound. In particular, most of the time is likely spent in decoding RPC results which isn't done efficiently in python due to the GIL. One of the problems with Appstats is that it measures RPC timing from when the RPC is sent to when get_result() is called. This means that time spent before get_result is called will appear to be coming from the RPCs.

    If you instead issue IO-bound RPCs (i.e. queries that make the Datastore work harder) you will start to see the performance gains of parallel queries.

    0 讨论(0)
提交回复
热议问题