Building Google Cloud Platform Solutions
上QQ阅读APP看书,第一时间看更新

Scheduled tasks

The App Engine Cron Service gives developers a way to schedule regularly occurring tasks in the form of a cron.yaml definition file. This file specifies one or more tasks in the form of a description, a URL, and a human-readable schedule:

cron:
- description: a basic description of the task's purpose
url: /example/endpoint
target: colors
schedule: every 30 minutes from 9:00 to 13:00
retry_parameters:
job_retry_limit: 3

 

At the specified times, the App Engine Cron Service will perform an HTTP GET request on the provided URL of the target service. In the preceding snippet, a GET will be performed on the /example/endpoint URL of the colors service. If no target is specified, the default service will be used.

Upon receiving a request, the service can perform whatever business logic is needed before notifying the cron service of the task's success or failure. Success and failure are denoted by the returned HTTP status code, where any 2XX status code represents success, and all other status codes represent failure. The status and history of scheduled tasks can be viewed from within the Cloud Console at Navigation menu | App Engine | Task queues in the Cron Jobs tab.

The cron service has robust support for retry logic, as defined by the retry_parameters configuration block in cron.yaml. Retries are performed with exponential backoff, where each successive retry is delayed by twice the previous retry delay, up to a maximum value defined in max_backoff_seconds or max_doublings; whichever occurs first. Note that unless specified, no retries will be attempted.