适用于Google App Engine标准环境的max_num_instances [英] max_num_instances for Google App Engine Standard Environment

查看:55
本文介绍了适用于Google App Engine标准环境的max_num_instances的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当前,我正在使用Google App Engine标准环境(Python)运行应用程序

在每天重置24小时免费配额之前仅 1或2小时,我将用完所有 28个实例小时

我的流量模式通常大部分时间都处于低流量状态,除了在夜间8小时左右会处于高流量状态.

我的 app.yaml 几乎全部恢复为所有默认设置

 应用程序:my-webapp版本:1运行时:python27api_version:1线程安全:false 

我仍然想依靠 automatic_scaling .我希望稍微降低我的App引擎性能,以换取不收取每日费用.

在灵活的环境中,我意识到这里有一个我们可以指定的配置

已创建5个实例,但它们都不处于活动状态?!

现在,我只处理了2k个请求,但已经消耗了16.8个实例小时


与我的另一个应用程序相比,该应用程序提供更高的流量(但延迟更短).它始终只有1个实例.到目前为止,仅消耗了8.43个实例小时

我的流量较高的应用程序yaml文件中没有任何特殊参数.因此,我不确定为什么它们产生的实例数量有所不同.

解决方案

如果您的应用支持(并非所有应用都支持!-取决于它们的编码方式),请尝试设置 threadsafe:true ,允许一个实例并行处理多个请求,这将减少总的请求延迟,从而帮助GAE自动缩放器决定启动更少的实例.如果可行,您还可以尝试调整相关的 max_concurrent_requests .

另一种尝试的方法是通过 min_pending_latency max_pending_latency 通知自动缩放器您的应用程序可以承受更高的请求延迟.相关:

max_idle_instances 设置为1(如果可以的话,甚至设置为0),以防止自动缩放器启动空闲实例,这些实例实际上并不能为服务流量带来很大帮助.参见什么将auto_scaling max_idle_instances设置为零(0)可以吗?

最后,如果您真的想对实例编号加一个硬上限,则可以切换到基本扩展,它具有 max_instances 配置选项.但是请注意,如果您突然有很高的请求负载,这会严重降低用户体验.

Currently, I'm running an application using Google App Engine Standard Environment (Python)

With only 1 or 2 hours before the free quota 24 hours daily reset, I will use up all the 28 instance hours

My traffic pattern is low most of the time, except it will be high around 8 hours during night-time.

My app.yaml pretty much fall back to all default settings

application: my-webapp
version: 1
runtime: python27
api_version: 1
threadsafe: false

I would still like to rely on automatic_scaling. I wish to downgrade my app engine performance a bit, in exchange of no daily charge.

In Flexible Environment, I realize there's a config where we can specific

https://cloud.google.com/appengine/docs/flexible/python/configuring-your-app-with-app-yaml

automatic_scaling:
  min_num_instances: 1
  max_num_instances: 1

I would like to limit the maximum number of instance, in my App Engine Standard Environment. However, I don't find max_num_instances config in Standard Environment.

https://cloud.google.com/appengine/docs/standard/python/config/appref#scaling_elements

What I find the valid config under Standard Environment's automatic_scaling are

  • max_concurrent_requests
  • max_idle_instances
  • max_pending_latency
  • min_idle_instances
  • min_pending_latency

I would like to utilize all 28 instance hours, slightly downgrade on performance, yet with no daily charge incurred :)

May I know, which config parameter I should start to fine tune to?


Update

I had tried

automatic_scaling:
  max_idle_instances: 1
  min_idle_instances: 0
  max_concurrent_requests: 80

However, it seems to make thing worst.

5 instances are created but none of them are active?!

Right now, I only served 2k request, but 16.8 instance hours already consumed


Compared to my another app, which serves higher traffic (But lower latency). It is always having 1 instance only. So far, only 8.43 instance hours consumed

I didn't have any special parameter in my higher traffic app yaml file. Hence, I'm not sure why there's difference in their number of spawned instances.

解决方案

If your app supports it (not all apps do! - it depends on how they're coded) try setting threadsafe: true, allowing one instance to serve multiple requests in parallel, which would reduce the overall request latency, thus helping the GAE autoscaler decide to launch fewer instances. If this works you can also try tweaking the related max_concurrent_requests.

Another thing to try would be to inform the autoscaler that your app can tolerate higher request latencies via min_pending_latency and max_pending_latency. Related:

Set max_idle_instances to 1 (or even 0, if you're able to) to prevent the autoscaler from starting idle instances that aren't actually helping much with serving traffic. See What does setting the automatic_scaling max_idle_instances to zero (0) do?

Finally, if you really want to put a hard cap on your instance number you can switch to basic scaling, which does have a max_instances configuration option. But be aware that this can seriously degrade user experience if you suddenly have a high request load.

这篇关于适用于Google App Engine标准环境的max_num_instances的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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