After running this in production, it turns out that on Python 2.7 with
thread safe enabled this small change cut our Instance hours by 64%.  YMMV
but for 3 lines of code that is HUGE.

I think this comes from the fact that you can write the output to the user,
and the process does other things while waiting for the commits to the
datastore, rather than waiting for the commit, THEN writing to the user,
blocking other processes the whole time.  So I think we gained concurrency
equal to the amount of time we were spending on waiting for the data store.

This was the single best 3 lines of code we ever changed. (well maybe other
than webapp2 so we could run thread safe).


-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Robert Kluin
Sent: Thursday, January 19, 2012 9:21 AM
To: [email protected]
Subject: Re: [google-appengine] Re: Put_Async Use It

On Thu, Jan 19, 2012 at 05:13, Brandon Wirtz <[email protected]> wrote:
> http://code.google.com/appengine/docs/python/datastore/functions.html
>
>
>
> Get Result will let you know if your Put has finished.  That way you
> can do other things while the put happens.  (or you can do what I do,
> and assume HRD won’t fail.

I see periodic runs of failures on HRD apps from time to time.  This can
range from temporary over per-minute quota errors (if your app is actually
doing much traffic) to other types of timeouts (you're not only waiting on
the datastore to write).

The advantage to async is what you've said here, it lets you do other stuff
rather than waiting for the write.  Note, however, as Jeff said, the request
will wait for all RPCs to return before it actually completes.  It doesn't
just start processing the next request.


>
>
>
>
>
> From: [email protected]
> [mailto:[email protected]] On Behalf Of Rohan
> Chandiramani
> Sent: Thursday, January 19, 2012 1:55 AM
> To: [email protected]
> Subject: Re: [google-appengine] Re: Put_Async Use It
>
>
>
> How would you check to see if the write was completed, with async
> there is no guarantee when the write actually takes place?
>
> --
> You received this message because you are subscribed to the Google
> Groups "Google App Engine" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/google-appengine/-/Q2tz2IqrL-QJ.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/google-appengine?hl=en.
>
> --
> You received this message because you are subscribed to the Google
> Groups "Google App Engine" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/google-appengine?hl=en.

--
You received this message because you are subscribed to the Google Groups
"Google App Engine" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-appengine?hl=en.



-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en.

Reply via email to