GAE send requests to all active instances

2019-07-28 12:00发布

Is there any way to send requests to all active instances of a module/service in Google App Engine?

If I can get the list of all the active instances ids, I could make a request like https://instance-dot-version-dot-service-dot-app-id.appspot.com for each instance.

I need this to change some memory's global variables (that saves me requests to datastore or memcache and time) in very unusual cases. If they were frequent changes I obviously would prefer to use memcache...

1条回答
可以哭但决不认输i
2楼-- · 2019-07-28 12:22

You can get the list of instances for a specific service version using the Google App Engine Admin API's REST apps.services.versions.instances.list method:

Lists the instances of a version.

HTTP request

GET https://appengine.googleapis.com/v1/{parent=apps/*/services/*/versions/*}/instances

The URL uses Google API HTTP annotation syntax.

See also the corresponding Google App Engine Admin API Client Library for Python's pydoc page here.

With the list of instances you can, as you mentioned, use GAE's routing via URL to send requests to each particular instance as desired.

Important note related to this assumption in the question:

If I can get the list of all the active instances ids, I could make a request like https://instance-dot-version-dot-service-dot-app-id.appspot.com for each instance.

from Targeted routing:

Note: Targeting an instance is not supported in services that are configured for auto scaling or basic scaling.

查看更多
登录 后发表回答