Is there any way to bundle 3rd party libraries with GAE Flex deployments?

57 views
Skip to first unread message

Parth Mishra

unread,
Jul 12, 2018, 12:34:25 PM7/12/18
to Google App Engine
For a Python GAE Flex environment, I know you can specify dependencies in the "requirements.txt" file. However, if I'm understanding this correctly, each time an instance is started up, the requiremnts will have to be redownloaded from the internet (for 3rd party libraries) which I imagine slows down startup time significantly. 

is it possible to bundle these libraries with a deployment? In GAE Standard, you can bundle your 3rd party libraries that with the deployment which ensures quick runtime but I don't see any such option enabled for Flex. Is this possible? How else can I reduce startup times for flex instances? 

George (Cloud Platform Support)

unread,
Jul 13, 2018, 10:56:41 AM7/13/18
to Google App Engine
The Python run-time will automatically install all dependencies declared in your requirements.txt file during deployment. The library loading delay impact on start-up time is usually negligible; it may become a problem though, for instance in case of large third-party libraries. Related information may be found on the "Using Python Libraries" documentation page

You have some means at your disposal to speed up your instance start up, such as using warm-up requests, lazy-loading your imports, or in the most extreme case, pruning your dependency tree. More detail on the subject may be found on forum articles such as "Best practices for App Engine startup time: Google Cloud Performance Atlas" in the Google Cloud Platform Blog

Parth Mishra

unread,
Jul 15, 2018, 3:09:03 PM7/15/18
to Google App Engine
I'm still not clear based on that article, are the dependencies still always downloaded via the internet upon instance startup? I want to know because if I'm using a large library like OpenCV, the scaling for Flex instances would be even slower, would it not? Can you use warm-up requests in the flexible environment? 

George (Cloud Platform Support)

unread,
Jul 16, 2018, 1:01:40 PM7/16/18
to Google App Engine
As described in the linked blog page, during cold-boot time, your application code is busy scanning and importing dependencies. The longer this takes, the longer it will take for your first line of code to execute. Some languages can optimize this process to be exceptionally fast, other languages are slower, but provide more flexibility. 

//_ah/warmup requests are not supported in the App Engine flexible environment.

To warm up your app, implement a health check handler that only returns a ready status when the application is warmed up.

For example, you can create a readiness check that returns a ready status after initializing the cache so your app won't receive traffic until it is ready. You may find related information on the "Upgrading to the App Engine Flexible Environment Latest Release" page

Steren Giannini

unread,
Jul 16, 2018, 1:28:47 PM7/16/18
to google-a...@googlegroups.com
I confirm what George said: the dependencies are only downloaded and installed at deployment time. Instance startup does not download the dependencies from the internet.

--
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 google-appengi...@googlegroups.com.
To post to this group, send email to google-a...@googlegroups.com.
Visit this group at https://groups.google.com/group/google-appengine.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-appengine/df4f4126-9983-4677-8753-33b72406040f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages