GAE向所有活动实例发送请求 [英] GAE send requests to all active instances

查看:174
本文介绍了GAE向所有活动实例发送请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么方法可以向Google App Engine中的模块/服务的所有活动实例发送请求?



如果我可以获取所有活动实例的列表ID,我可以提出请求,如 https:// instance- dot-version-dot-service-dot-app-id.appspot.com 为每个实例。



我需要这个来改变一些内存的全局变量(这可以节省我对数据存储或memcache的请求和时间)。如果他们经常发生变化,我显然会更喜欢使用memcache ...

解决方案

您可以获取特定实例的列表服务版本使用 Google App Engine管理API 的REST apps .services.versions.instances.list 方法:


列出版本的实例。



HTTP请求



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



URL使用 Google API HTTP注释语法。


参见上文o相应的适用于Python的Google App Engine管理API客户端库

a>的pydoc页面这里

如您所述,使用GAE的通过URL路由根据需要向每个特定实例发送请求。

重要提示在这个问题中涉及到这个假设:


如果我能得到所有活动实例的列表id ,我可以做
请求,如
https://instance-dot-version-dot-service-dot-app-id.appspot.com ,每个实例


来自定位路由


注意:定位实例不支持在配置为自动缩放或基本缩放的服务中使用。


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...

解决方案

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.

这篇关于GAE向所有活动实例发送请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆