Thanks for explaining how api cpu usage is calculated.
I haven't enable billing yet, so my quota is low, but every time I
invoke a background task that do batch commits, the api_cpu is in red,
warning me the quota might be reached.
Most of the my service calls involve 1+ datastore call, that force the
api_cpu be 80%+ of all cpu. That means api_cpu quota is my bottleneck,
and I must improve/avoid api_cpu to be more scalable.
Right now I am doing performance optimization, logging every api call
and try to eliminates them, and observe the following behavior and
wondering if others see the same.
1. The api_cpu of batch put is more sensitive to the number of
entities stored than the actual size of the payload. For example,
storing 10 small entities 1k each) might take as much api_cpu to store
a single 100k entity.
2. Using batch put save more on the delay of the call, but doesn't
save much on cpu quota.
3. 1-N owned relationship (JDO specific?) is expensive (I see query on
child (list of entities) when a put is done on the parent)
4. With JDO, whenever it feels the need to do a query before a put, it
wraps the query+put with a transaction (begin and commit), these extra
3 api calls take more api_cpu.
These makes me to believe that, to optimize api_cpu,
A. If child objects are small and will not be searched, they should be
modeled as a list of serializable items instead of a 1-n owned
relationship. This is aligned with #1 and #2 and avoid some #3 and #4.
B. It saves api_cpu to stuff logically related entities into a wider
schema to avoid query and batch put.
It will be very helpful if someone can provide a rough formula on how
api_cpu is consumed, given the number of entities, entity size, etc...
If anyone here want to share optimization tips on api_cpu, please
advice. :)
Thanks!
On Sep 11, 11:17 am, "Nick Johnson (Google)" <
nick.john...@google.com>
wrote:
> Hi Peter,