On Tue, Oct 14, 2014 at 12:28 PM, Kaan Soral <[email protected]> wrote:

> I've also tested F4 instances, got almost exactly the same template
> parsing performance compared to F2 instances, ~3300ms parsing templates,
> 5000ms to complete the warmup (probably initial library imports etc for the
> additional 1700ms)
>
> Shouldn't the template parsing time ~halve when I switch from F2 to F4?
>


Not necessarily. It should be faster, but not necessarily directly linked
to labeled CPU speed.

If you absolutely must get template render times as low as possible, I'd
suggest fiddling with Jinja bytecode caching:
http://jinja.pocoo.org/docs/dev/api/#bytecode-cache . Essentially, you'll
generate the template bytecode once, then can recall it from the datastore
for any other instances that need it, even newly created instances.
Individual instances will no longer need to render their own templates.
Here's a SO post about saving template bytecode to the datastore:
http://stackoverflow.com/questions/21330257/configure-auto-reload-template-and-enable-bytecode-cache-for-jinja2-in-appengine/21339526#21339526

I'm not sure all of that time can be blamed on the rendering. On the Java
runtime, I've occasionally noticed a similar phenomenon as yours: the first
request of an instance can sometimes have a higher failure rate/processing
time than subsequent requests, especially when processing network IO (using
urlfetch, talking to GCS, etc). My suspicion (that I have no evidence for,
this is speculation on my part) is that the App Engine infrastructure
doesn't fully finish initializing and linking up a newly-spawned instance
with network services until the first request is in-flight.

If you have time and want to play around a bit (and I am NOT suggesting
this for actual production use), I would suggest this: try embedding the
template text as a multiline string within your Python script, then loading
your template from the string. It's going to make your source files look a
bit messy, but it'll definitively answer the issue of whether this time
spent is entirely the fault of the renderer, or due to another blocking
service.



-----------------
-Vinny P
Technology & Media Consultant
Chicago, IL

App Engine Code Samples: http://www.learntogoogleit.com

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-appengine.
For more options, visit https://groups.google.com/d/optout.

Reply via email to