Google App Engine:不可预测的成本以及 App Engine 仪表板与计费导出之间的差异

Google App Engine: unpredictable cost and discrepancy between app engine dashboard vs billing export

我已经研究了 2 周的小型数据科学 Web 应用程序的 App Engine 设置。由于这是一个用我自己的钱包收费的个人项目,我在 app.yaml 中尝试了几个不同的参数来降低“前端实例”成本。几个变化,我得到了意想不到的 ~10 倍的成本激增!!!很痛!!!为了不浪费它,我决定在这里学习一些东西来理解行为:)...别担心,我已经暂时关闭了我的应用程序;)

版本 1 app.yaml:

service: my-app
runtime: python37
instance_class: F4
env: standard
automatic_scaling:
  min_idle_instances: 1
  max_idle_instances: 1
default_expiration: "1m"

inbound_services:
- warmup

entrypoint: gunicorn -b 0.0.0.0:8080 main:server

版本 1,计费结果(usage.amount_in_pricing_units 从计费帐户导出):~100 小时/天,与 App Engine 计费状态中显示的 Front end Instance Hours 相同。 这是可以理解的,因为我有一个 F4 实例一直处于空闲状态,这将转化为 24*4=96 个前端实例小时。从实际请求(仅来自我)添加实例使用情况,~100 小时/天似乎是合理的。

版本 2,我打算在其中降低实例 class 和实例数量,并延长 default_expiration 并希望它能帮助应用程序更快地启动和我想做的其他一些事情以为影响不大....

service: my-app
runtime: python37
instance_class: F2
env: standard
automatic_scaling:
  min_instances: 1
  max_instances: 1
  target_cpu_utilization: 0.85
  max_concurrent_requests: 80
  max_pending_latency: 6s
default_expiration: "3h"

inbound_services:
- warmup

entrypoint: gunicorn -b 0.0.0.0:8080 main:server

版本 2,计费结果(usage.amount_in_pricing_units 从计费帐户导出):~800 小时+/天,哎哟!!!相比之下,来自 App Engine 仪表板的 Front end Instance Hours 计费状态低于预期的 60 小时/天。这是我迷路的地方:

  1. 为什么来自计费的使用量比 App Engine 仪表板大得多,这些使用量从何而来?

  2. 在哪里可以找到和跟踪 App Engine 仪表板等中未计算使用情况的指标?

2020-01-16 问题 #1 的解决方案。

在等待 Google 计费支持回复我时,我发现了这个:

也就是说,过去部署的应用程序版本也在占用前端实例小时数,这需要真实世界的确认。 (令我惊讶的是,这与app.yaml文件无关!!)所以我删除了所有过去版本的应用程序并让它运行两天,同时观察实例时间和账单记录以下 app.yaml 个文件。

service: my-app
runtime: python37
instance_class: F2
env: standard
automatic_scaling:
  min_instances: 1
  max_instances: 2
  max_idle_instances: 1
  target_cpu_utilization: 0.85
  max_concurrent_requests: 80
  max_pending_latency: 6s
default_expiration: "1m"

inbound_services:
- warmup

entrypoint: gunicorn -b 0.0.0.0:8080 main:server 

这应该总是有一个 F2 实例 运行ning 并且最多可以有 2 个实例。这次 App Engine 和导出的计费使用时间均同意 50 小时的前端实例小时数。是的!!!每日费用降低到1/16

这解决了费用问题 #1,但问题 #2 仍有待回答。应用引擎仪表板没有显示前端实例的所有计费使用情况,这是一个非常有问题的问题。昨天我从 Google Billing Support Team 那里听说,答案没有帮助(主要是谈论 app.yaml 中的实例编号,这没有帮助),他们似乎没有注意到这个问题,我将不得不让他们知道。

2020-01-31 问题 #2 的跟进

Google 计费支持团队迅速做出回应,承认 App Engine 仪表板与计费导出之间存在差异,并同意为我调整计费。结果,高峰期的账单实际上得到了退款。向他们致敬!