Google App Engine Flexible环境的定价,一堂$ 500的课程 [英] Pricing of Google App Engine Flexible env, a $500 lesson

查看:93
本文介绍了Google App Engine Flexible环境的定价,一堂$ 500的课程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遵循了Nodejs on App Engine Flexible env教程@: https://cloud.google.com/nodejs/getting-started/hello-world

I followed the Nodejs on App Engine Flexible env tutorial @: https://cloud.google.com/nodejs/getting-started/hello-world

在成功部署并测试了本教程之后,我将代码进行了一些实验,然后成功部署了它……然后由于它是一个测试环境(而不是公共环境)而使它继续运行.

Having successfully deployed and tested the tutorial, I changed the code to experiment a little and successfully deployed it... and then left it running since this was a testing environment (not public).

一个月后,我收到了Google的一张超过$ 370的帐单!

A month later, I receive a bill from Google for over $370!

在交易详细信息中,我看到以下内容:

In the transaction details I see the following:

2017年10月1日至31日,App Engine Flex实例RAM:5948.774 Gibibyte-hours ([MYPROJECT])$ 42.24

Oct 1 – 31, 2017 App Engine Flex Instance RAM: 5948.774 Gibibyte-hours ([MYPROJECT]) $42.24

2017年10月1日至31日,App Engine Flex实例的核心小时:5948.774小时([MYPROJECT])$ 312.91

Oct 1 – 31, 2017 App Engine Flex Instance Core Hours: 5948.774 Hours ([MYPROJECT]) $312.91

这个几乎有0个请求的测试环境如何需要大约6,000个小时的资源?在最坏的情况下,我会假设一个小时的全职工作720小时@每小时$ 0.05,将使我花费$ 40. https://cloud.google.com/appengine/pricing

How did this testing environment with almost 0 requests require about 6,000 hours of resources? In the worst, I would have assume 720 hrs running fulltime for a month @ $0.05 per hour would cost me ~$40. https://cloud.google.com/appengine/pricing

有人可以帮助阐明这一点吗?我无法找出为什么需要这么多资源?

Can someone help shed light on this? I have not been able to find out why so many resources were needed?

感谢您的帮助!

有关更多数据,这是上个月的流量(基本上为0):

For more data, this is the traffic over the last month (basically 0):

和实例数据

更新: 请注意,我确实对package.json进行了修改:我将nodemon添加为依赖项,并将其添加为"nmp start"脚本的一部分.虽然我怀疑这解释了6000个小时的资源:

UPDATE: Note that I did bring one modification to the package.json: I added nodemon as a dependency and added it as part of my "nmp start" script. Though I doubt this explains the 6000 hours of resources:

  "scripts": {
    "deploy": "gcloud app deploy",
    "start": "nodemon app.js",
    "dev": "nodemon app js",
    "lint": "samples lint",
    "pretest": "npm run lint",
    "system-test": "samples test app",
    "test": "npm run system-test",
    "e2e-test": "samples test deploy"
  },

App.yaml(默认值-与教程无变化)

App.yaml (default-no change from tutorial)

runtime: nodejs
env: flex

推荐答案

在与Google进行了多次来回交流,以及数小时的博客阅读和报告查看后,我终于(某种程度上)找到了发生情况的解释.我将在这里发表我的建议,以便其他人也不会成为这个问题的受害者.

After multiple back and forth with Google, and hours of reading blogs and looking at reports, I've finally (somewhat) found an explanation for what happened. I will post it here with my suggestions so that other people do not also fall victim to this problem.

注意,这对于某些人来说似乎很明显,但是作为GAE的新用户,所有这些对我来说都是全新的.

Note, this may seem obvious to some, but as a new GAE user, all of this was brand new to me.

简而言之,当部署到GAE并使用以下命令" $ gcloud app deploy "时,它会创建一个新版本并将其设置为默认版本,但更重要的是,它不会删除已部署的先前版本.

In short, when deploying to GAE and using the following command "$ gcloud app deploy", it creates a new version and sets it as the default, but also and more importantly, it does NOT remove the previous version that was deployed.

有关版本和实例的更多信息,请参见:

More info about versions and instances can be found here: https://cloud.google.com/appengine/docs/standard/python/an-overview-of-app-engine

因此,就我而言,我不知道它是否创建了简单节点应用程序的多个版本.这些版本仍在运行,以防出现错误后需要进行切换.但是这些版本也需要实例,除非在app.yaml中声明,否则默认实例是2个实例.

So in my case, without knowing it, I had created multiple versions of my simple node app. These versions are still running in case one needs to switch following an error. But these versions also require instances, and the default, unless stated in the app.yaml, is 2 instances.

Google说:

默认情况下,App Engine会缩放正在运行的实例的数量, 向下以匹配负载,从而为您提供一致的性能 应用程序,同时最大程度地减少空闲实例,从而减少 费用.

App Engine by default scales the number of instances running up and down to match the load, thus providing consistent performance for your app at all times while minimizing idle instances and thus reducing cost.

但是,根据我的经验,事实并非如此.如前所述,我使用nodemon推送了我的节点应用程序,这似乎导致了错误.

However, from my experience, this was not the case. As I said earlier, I pushed my node app with nodemon which it seems was causing errors.

最后,按照教程并没有关闭项目,我有4个版本,每个版本有2个实例,这些实例全职运行1.5个月,为0个请求提供服务,并生成大量错误消息,并且花了我500美元.

In the end, following the tutorial and not shutting down the project, I had 4 versions, each with 2 instances running full-time for 1.5 months serving 0 requests and generating lots of error messages and it cost me $500.

如果您仍然想使用GAE FLEX ENV的建议:

  1. 首先,请设置结算预算和&发出警报,这样您就不会对会自动从您的CC中收取的昂贵发票感到惊讶: https://cloud.google.com/billing/docs/how-to/budgets

在测试环境中,您很可能不需要多个版本,因此在部署时,请使用以下命令:
$ gcloud app deploy --version v1

In a testing env, you most likely do not need multiple versions, so while deploying use the following command:
$ gcloud app deploy --version v1

更新您的 app.yaml ,以仅使用最少的资源强制执行一次实例:

Update your app.yaml to force only 1 instance with minimal resources:

runtime: nodejs
env: flex

# This sample incurs costs to run on the App Engine flexible environment.
# The settings below are to reduce costs during testing and are not appropriate
# for production use. For more information, see:
# https://cloud.google.com/appengine/docs/flexible/nodejs/configuring-your-app-with-app-yaml
manual_scaling:
  instances: 1
resources:
  cpu: 1
  memory_gb: 0.5
  disk_size_gb: 10

  1. 设置每日支出限额

有关更多信息,请参见此博客文章:

See this blog post for more info: https://medium.com/google-cloud/three-simple-steps-to-save-costs-when-prototyping-with-app-engine-flexible-environment-104fc6736495

我希望这些步骤中的某些步骤已包括在本教程中,以保护尝试学习和尝试的人,但事实并非如此.

I wish some of these steps had been included in the tutorial in order to protect those who are trying to learn and experiment, but it was not.

如果一个人不知道所有这些详细信息,那么Google App Engine Flex环境可能会很棘手.一位朋友向我指出了Heroku,它既有定价又有免费/业余爱好优惠.我能够在那里快速推送一个新的节点应用程序,它的工作原理很吸引人! https://www.heroku.com/pricing

Google App Engine Flex env can be tricky if one does not know all these details. A friend pointed me to Heroku, that has both set pricing and Free/Hobby offers. I was able to quickly push a new node app there, and it worked like charm! https://www.heroku.com/pricing

仅"花费了我$ 500来学习本课程,但是我希望这对其他使用Google App Engine Flex Env​​的人有所帮助.

It "only" cost me $500 to learn this lesson, but I do hope this helps others looking at Google App Engine Flex Env.

这篇关于Google App Engine Flexible环境的定价,一堂$ 500的课程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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