【发布时间】:2015-09-24 07:43:45
【问题描述】:
我想试试 dropwizard-metrics + 石墨。
为了解决这个问题,我需要定期运行一个作业(例如每 5 秒),将指标从实例发送到石墨服务器。
这可能吗?
【问题讨论】:
我想试试 dropwizard-metrics + 石墨。
为了解决这个问题,我需要定期运行一个作业(例如每 5 秒),将指标从实例发送到石墨服务器。
这可能吗?
【问题讨论】:
App Engine 中 Cron 的 java documentation 和 python documentation 表示 App Engine 中的最小间隔可以以“分钟”为单位进行配置。因此,简单的答案是:不,您不能每 5 秒安排一次作业。
但是...
知道任务队列任务最多可以运行 10 分钟 (see deadlines),您可以手动每(假设)5 分钟安排一次任务,并在您的 servlet 中自己处理 5 秒间隔(或在 python 中调用的任何内容) )。
我只是说可以使用这样的短间隔。你真的应该避免这样的拐杖。这种行为会吃光你的配额,让你的应用很快变得昂贵。
编辑:
由于问题的标题要求在特定情况下运行作业:
正如 Dmitry 所指出的和 here 所记录的那样,当使用 manual 或 basic 扩展模块时,可以解决特定实例。使用自动扩展时,实例是匿名的,因此无法解决。似乎此功能仅记录在案并适用于应用引擎模块。
【讨论】:
version 或module 上执行作业,但不能在运行如version 或modules 的特定实例上执行。应用引擎的全部意义在于不用担心服务器实例,因此它们不会让您显式访问它们。
Instances are addressable at URLs with the form: http://instance.version.module.app_id.appspot.com`. If you have set up a wildcard subdomain mapping for a custom domain, you can also address a module or any of its instances via a URL of the form `http://module.domain.com` or `http://instance.module.domain.com`. You can reliably cache state in each instance and retrieve it in subsequent requests.