python - Why is my RPC total going up? -
i'm trying optimize code, , got problem don't quite understand. on every page of web app, there list of notifications facebook's new ticker. so, on every request, run code in beggining:
notification_query = db.query(ticker, keys_only=true)\ .filter('friends =',self.current_user.key().name()) self._notifications_future = notification_query.run()
then, find spot, call middle function is:
notification_keys = [future.parent() future in self._notifications_future] self._notifications = db.get_async(notification_keys)
finally fetch them @ end:
context.update({'notifications': self._notifications.get_result() })
every thing works great except this: if call middle function in end of request's function, this:
dumb spot
and if call in think optimized spot, this:
smart spot
as can see api usage doubled making "optimization". going on here?
call number 2, first snippet in both cases. call number 12 in dumb spot second snippet, , call number 12 in smart spot second snippet. last switch, has nothing problem, i've tested it.
pd: google charge me time query "idle"?
update
the problem seems in dev_server, when tried same example (smart version) on appspot, got this:
queries on appspot
here works expected, things called run() or get_async() don't block other stuff. said issue in dev_server. still nice see feature working on localhost, more effective profiling.
ahhhh. helpful when posting app engine mention if results on dev server or in production. dev server not have same performance characteristics production servers, not best way profile application. in fact, believe indexes not used @ all, , dev server single threaded, can't handle concurrent requests it. in fact, if app makes calls itself, it won't work @ all!
Comments
Post a Comment