【问题标题】:How to scale down to 0 instances in GAE Standard Go如何在 GAE Standard Go 中缩减到 0 个实例
【发布时间】:2018-12-18 17:20:07
【问题描述】:

我已将 Golang 应用部署到 Google Cloud Platform 的 App Engine 标准环境。

我的 app.yaml 包含以下几行:

  automatic_scaling:
  min_idle_instances: 0
  max_idle_instances: 0
  min_pending_latency: automatic
  max_pending_latency: automatic
  min_instances: 0
  max_instances: 2

我的目的是让应用在空闲时缩减到 0 个实例,并生成最多 2 个实例来处理传入请求。

调用该服务后,我注意到它永远不会缩减到 0 个实例。

我在web控制台打开服务配置,发现如下:

runtime: go
api_version: go1
env: standard
threadsafe: true
instance_class: F1
handlers:
  - url: /penguin
    script: _go_app
automatic_scaling:
  min_idle_instances: automatic
  max_idle_instances: automatic
  min_pending_latency: automatic
  max_pending_latency: automatic
  max_instances: 2

是否可以将 App Engine 标准服务缩减到 0 个实例?在 yaml 中应该是什么样子?

【问题讨论】:

  • App Engine Standard 默认缩减为 0 个实例。如果您从 app.yaml 文件中删除 automatic_scaling 并重新部署,是否仍会产生实例(例如在初始部署后几分钟)?
  • 怕没有运气。删除“automatic_scaling:”及其下方的所有内容。重新部署并且配置现在显示:`自动缩放:min_idle_instances:自动max_idle_instances:自动min_pending_latency:自动max_pending_latency:自动`它似乎默认回到自动
  • 我向服务发送了 1000 个请求,云控制台确认有一个实例正在运行。我会等一个小时(或几个小时),看看它是否缩放到 0
  • 看起来还有一个实例。但是,“计费实例估计”目前为 0。我希望这意味着我认为的意思。感谢@swigganicks 的帮助
  • @swigganicks 你能把它创建为答案,这样我就可以“打勾”

标签: google-app-engine go google-cloud-platform


【解决方案1】:

App Engine 标准环境默认缩减为 0 个实例,因此您不必在 app.yaml 中指定它。您只需要在自动缩放中指定要更改的值。有关automatic_scaling 下的默认缩放值列表,请参阅documentation

部署后,您最多只能显示 1 个实例,但您需要为使用量付费,即 0。

(另请注意,这适用于 App Engine 柔性环境)

【讨论】:

  • 没有为min_idle_instances指定默认值。
  • @swigganicks 你不应该看到两个实例吗?因为它是默认值。
  • @Ale 默认为 flex env 不标准
  • _ 部署后,您最多只能显示 1 个实例,但您需要为使用量付费,即 0。_ 如果您运行的是 F1 以外的实例类,则情况并非如此。任何大于此值的内容仍将按实例小时计费,因为 28 小时免费仅适用于 F1 实例。
猜你喜欢
  • 2020-12-03
  • 2020-07-15
  • 1970-01-01
  • 2016-08-13
  • 1970-01-01
  • 2020-01-28
  • 2018-05-27
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多