Google App Engine - 通过实例自动缩放? [英] Google App Engine - automatic-scaling with always on instance?

查看:104
本文介绍了Google App Engine - 通过实例自动缩放?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果在15分钟内没有人碰到你的服务器,那么将GAE用于全新应用程序最令人恼火的事情之一就是不得不处理被激发的实例。由于该应用程序是新的,或者只有很少的用户,所以对于那些不知道实例正在旋转的用户来说,会出现很大的延迟时间。

就我所见,您可以根据文档选择这些选项:



使用手动缩放并将实例数设置为 1 手动缩放时,无论您将其设置为多少个实例,都可以使用

是你将会拥有的 - 不多也不少。这显然是低效的,因为您可能会支付未使用的实例,并且实例不会随着流量增加/减少而自动添加/删除。

使用基本缩放并将空闲超时设置为24小时或48小时。



只要有人在该时间段内至少查询一次您的API,就会让您的实例继续运行。



使用使用 min-idle-instances 自动缩放并启用预热请求。



这不符合预期。根据这些文档


如果您的应用程序没有提供任何流量,则对应用程序的第一个请求将是
始终是加载请求,而不是热身请求。


这并不能解决我们的问题,因为如果有零个实例在运行,那么首先就没有什么可以预热的。因此,您仍然会在第一次请求时收到延迟。






我希望得到的效果是 strong>始终有一个实例运行,然后从该处扩展(如果流量增加)(当然,缩小但不会低于一个实例)。这将像自动缩放,但有1个实例始终运行。



这在GAE中可能吗?或者我错过了什么?



目前,我的临时解决方案是将我的应用程序设置为手动缩放 1实例,所以至少我的应用程序可用于新用户。

解决方案

我尝试过的一种解决方案是使用自动 - 缩放和发布cron作业,每5分钟左右执行一次servlet中的任何公共静态api方法(它可以只取零参数并返回null)。

请参阅此处以了解如何设置: https://cloud.google.com/appengine/docs/java/config/cron#creating_a_cron_job



这会让您28个免费实例小时与使用手动缩放8个小时的好处:) woot woot


One of the most irritating things about using GAE for a brand new app is having to deal with instances being fired back up if no one has hit your servers in 15 minutes. Since the app is new, or just has few users, there will be periods of great latency for some users who have no clue that instances are being "spun up"

As far as I see it you have these options based on the docs:

Use manual-scaling and set the number of instances to 1.

When you use manual-scaling, whatever number of instances you set it to is what you will have - no more, no less. This is clearly inefficient as you may be paying for unused instances and instances are not automatically added/removed as traffic increases/decreases

Use basic-scaling and set idle-timeout to something like 24hrs or 48hrs.

This would keep your instance running as long as someone queries your API at least once within that time period.

Use automatic-scaling with min-idle-instances and warm-up requests enabled.

This does not work as intended. According to these docs:

if your app is serving no traffic, the first request to the app will always be a loading request, not a warmup request.

This does not solve our problem because if zero instances are running, then there is nothing to warm-up in the first place. Thus you still get latency on the first request.


The desired effect I would like to have is to always have an instance running and then scale up from there if traffic is increased (and of course scale down but never go below one instance). It would be like automatic-scaling but with 1 instance always running.

Is this possible in GAE? Or am I missing something?

For now, my temporary solution is to set my app to manual-scaling with 1 instance so at least my app is useable to new users.

解决方案

One solution that I tried and works is to use automatic-scaling and issue a cron job that just executes any public static api method (it can just take zero params and return null) in a servlet every 5 minutes or so.

See here for how to set that up: https://cloud.google.com/appengine/docs/java/config/cron#creating_a_cron_job

This gives you the benefit of 28 free instance hours vs using manual scaling's 8 hours :) woot woot

这篇关于Google App Engine - 通过实例自动缩放?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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