This guide describes how to configure your app to handle warmup requests. Warmup requests are used by the App Engine scheduler, which controls the auto scaling of instances based on user-supplied configuration. With warmup requests enabled, App Engine issues
/_ah/warmup. You can implement handlers for this request to perform application-specific tasks, such as pre-caching application data.
Enabling warmup requests
When warmup requests are enabled, the scheduler starts up instances when it determines that more instances are needed. Warmup requests may appear in logs even if they are disabled because the scheduler uses them to start instances.
Note that warmup requests are not guaranteed to be called. In some situations loading requests are sent instead: for example, if the instance is the first one being started up, or if there is a steep ramp-up in traffic. However, there will be a "best effort" attempt to send requests to already warmed-up instances if warmup requests are enabled.
In PHP, warmup requests are disabled by default. To enable them,
- warmup to the
directive in the
app.yaml file, for example:
inbound_services: - warmup
Registering your handler
To register your handler, define the script to handle your warmup requests in
app.yaml file. For example:
inbound_services: - warmup handlers: - url: /_ah/warmup script: warmup.php login: admin
This example registers a handler to listen to warmup requests to the
/_ah/warmup request path with the
Creating your handler
Build any logic that you need to run, into a handler that you map to respond to
/_ah/warmup request path. The following example builds on the previous
<?php // warmup.php // Handle your warmup logic in the PHP handler script as needed // for your app. echo "Warmup successful"; ?>
The examples above provide a framework to use. Next, decide what logic belongs in your warmup request handlers. You might want to add values into memcache that your application will need. For example, if you build and store a list of the current trending articles for your site, building that list in the warmup and then storing the necessary data in memcache means that when a user request comes in, the application has everything ready to serve and no queries are performed on the user's request for that data, which results in a faster response. Related topics:
- Learn more about Memcache