Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google App Engine: Warmup/Loading Requests and Always On

My understanding of a warmup request is that it is a request to "prime" a new frontend/backend instance (or do they only apply to frontends?) in preparation of being used at some point in the near future.

My understanding of a loading request is that it is a request to spin-up a new instance because it is needed right now. Hence, it would behoove oneself to try and "warm up" instances ahead of time, to make loading latency that much less.

So my first question is: is my understanding of these request types correct, and if not (or if I'm missing anything noteworthy here), then please begin by clarifying/correcting me!

Next I'm curious: how do you get your GAE server-side code to "handle" a warmup or loading request? Is there a specific interface I need to implement (in Java EE land, you need too implement ServiceContextListener which the web/app container looks for and calls when an app is deployed/started). If so, what is the API for doing so? Otherwise, what is the "entry point" for a GAE app? Basically I'm wondering what class/method should be handling warmup/loading requests.

Last, I ask: what (general) activities should be different in the startup process between the handling of warmup requests and loading requests? Wouldn't they be the same? I ask because I'm interested in using GAE's "Always On" premium feature, and not really sure where I should place my startup code for the instances that will always be on.

like image 986
Bantha Fodder Avatar asked Oct 24 '12 00:10

Bantha Fodder


People also ask

Is App Engine always running?

App Engine attempts to keep manual and basic scaling instances running indefinitely. However, at this time there is no guaranteed uptime for manual and basic scaling instances.

What are warmup requests?

Warmup requests load your app's code into a new instance before any live requests reach that instance. If warmup requests are enabled for your application, App Engine attempts to detect when your application needs a new instance and initiates a warmup request to initialize a new instance.

What are the three modes of scaling in App Engine?

There are actually three types of scaling in App Engine: Automatic, Basic, and Manual.


1 Answers

Warm up requests are a way to get an instance ready to handle traffic so that your users don't have to wait while a Java or Python app loads up all of its imports and then does any instance-specific initialization (including cache warming) that it needs to do. Warmup requests apply to both frontends and backends.

Details of how you do that depend on the language, but basically you need a handler for requests to /_ah/warmup that produces something other than a 500 response. For details, Google for "App engine warmup request" and pick the appropriate results. Warmup requests are enabled by default for Java, but for Python you have to enable them in your app.yaml. I haven't tried them yet for Go.

A 'loading request', as far as I know, is just a name given to the first request that an instance has to handle. https://developers.google.com/appengine/kb/java#What_Is_A_Loading_Request has some details.

like image 171
Dave W. Smith Avatar answered Oct 24 '22 23:10

Dave W. Smith