gho5t
gho5t

Reputation: 23

Warm Up or Start Service Based on Another Service on App Engine

I have two services on an App Engine project. Service A has a minimum 1 instance. Service B scales to 0. I would like when Service A receives a request, for Service B to receive a warm up request, or be initiated in some way. This is because users of the web application will primarily interact with Service A, and Service B just performs a couple heavy lifting tasks, which would be costly to have on all the time. However when the user is active, I would like to have Service B ready to go.

In other words, I need to Service B have an idle instance available only when Service A has been used recently. Is there a way to perform this?

Upvotes: 2

Views: 225

Answers (1)

GAEfan
GAEfan

Reputation: 11360

The simplest way is to just use a dispatch.yaml:

https://cloud.google.com/appengine/docs/standard/python/reference/dispatch-yaml

Then, create a @before_request handler (it's a Flask thing) in Service A, and have it ping the Service B warmup url.

You could also create separate yaml files for each service, and have the url handler you want in serviceB.yaml (but not in serviceA.yaml).

https://cloud.google.com/appengine/docs/standard/python3/configuration-files

HINT: Make sure you deploy each of the newly-created yaml files using gcloud deploy

Upvotes: 2

Related Questions