0

Google App Engine documentation indicates the two following information:

1- App Engine reserves automatic scaling capacity for applications with low latency, where the application responds to requests in less than one second. (https://cloud.google.com/appengine/docs/standard/python3/how-requests-are-handled)

2- App Engine tasks have specific timeouts that depend on the scaling type of the service that's running them. For worker services running in the standard environment:Automatic scaling: task processing must finish in 10 minutes. (https://cloud.google.com/tasks/docs/creating-appengine-handlers)

For compliance with (1), I'm writing APIs that defer any time-consuming processing to a CloudTask task, which allows my API to respond to all client requests in less that a second and benefit from auto-scaling.

But I also have to write the handlers that will perform the time-consuming processing on request of the Cloudtask service. I also want these handlers to be on GAE, and ideally to also get auto-scaling for these.

I do not see any formal declaration that would allow the GAE service to know whether a given part of my app is a client-facing API or a handler for tasks inserted in Cloudtask. Therefore I do not understand how GAE deals with the two requirements I quoted.

I'm worried that my task handler will deter my app performance metrics and as a result prevent auto-scaling.

Should I deploy these handlers in a different project? But then, how do I get auto scaling for these if they take more than 1 second to perform the task?

Alex
  • 1

1 Answers1

0

According to the official GCP documentation:

The offloaded task is added to a queue, which persists the task until it is successfully executed. The queue can also act as a kind of dispatch flow control, based on your initial configuration. You create and configure the queue which is then managed by the Cloud Tasks service. Once tasks are added, the queue dispatches them and makes sure they are reliably processed by your workers. Complexities associated with that process, such as user-facing latency costs, server crashes, resource consumption limitations, and retry management, are handled by the service.


Cloud Tasks queues with App Engine targets:

In the case of App Engine targets, the Cloud Tasks service also forwards the task request to the worker, located within App Engine, based on how the task (or, less commonly, the queue itself) is configured. These queues dispatch requests at a reliable, configurable rate. They guarantee reliable task execution - upon success, all workers must send an HTTP response code (200-299) to the Cloud Tasks service, in this instance before a deadline based on the instance scaling type of the service: 10 minutes for automatic scaling or up to 24 hours for manual scaling. If a different response is sent, or no response, the task is retried.

Because the handlers are part of App Engine, the Cloud Tasks service itself can do much of the process management for the task, scaling workers up and down in relation to traffic and deleting tasks when they are completed.


As an option, in order to minimize the latency, you could set different GAE worker services which will be responsible for task handling and then configure the routing for your tasks queue.

Deniss T.
  • 255
  • 1
  • 8