Configuring Warmup Requests to Improve Performance

This guide describes how to configure your app to handle warmup requests. With warmup requests enabled, the App Engine infrastructure issues GET requests to /_ah/warmup. You can implement handlers for this request to perform application-specific tasks, such as pre-caching application data.

Enabling warmup requests

In PHP, warmup requests are disabled by default. To enable them, add -warmup to the inbound_services directive in app.yaml:

inbound_services:
- warmup

Registering your handler

To register your handler, define the script to handle your warmup requests in your app.yaml file. For example:

application: your_project_id
# ...
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 `warmup.php` file.

Creating your handler

Build any logic that you need to run into a handler that you map to respond to the /_ah/warmup request path. The following example builds on the previous example:

<?php
  // warmup.php
  // Handle your warmup logic in the PHP handler script as needed
  // for your app.
  echo "Warmup successful";
?>

What's next

The examples above provide a framework to work within. Next, you'll want to 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:

Send feedback about...

App Engine standard environment for PHP