Google App Engine是否可以长时间运行但CPU任务少或轮询时间长? [英] Google App Engine for long running but low CPU tasks, or long-polling?

查看:52
本文介绍了Google App Engine是否可以长时间运行但CPU任务少或轮询时间长?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

App Engine非常适合快速处理的请求,而无需外部API调用数据库或缓存或第三方资源,但是我们发现,引入了任何类型的长时间运行"组件或外部延迟(例如,HTTP POST操作,该操作在后台异步运行,可能需要一两秒钟来处理一些更激烈的数据库查询...从客户端的UX角度来看,这是完全不可见的,而且还可以,因为这是异步的,但对于App Engine计费来说是昂贵的(因为它运行时间长)... ...实例时间"复合和驱动器成本大大增加.

App Engine has been great for requests that process quickly with no external API calls to databases or caches or third-party resources, but we've found that introducing any sort of "longer running" component or external latency (for example in a HTTP POST operation that runs asynchronously in the background and might take a second or two to process a few more intense database queries... totally invisible and OK from a UX perspective on the client-side because it's asynchronous but expensive to App Engine billing since it's long running) ... the "instance hours" compound and drive costs up considerably.

这类导致费用增加的情况是,请求实际上只是在等待外部资源的响应,并且在空闲期间似乎几乎需要零CPU,但我不确定这是可以避免的使用App Engine.

These sorts of expense inducing situations where a request is literally just waiting for a response from an external resource and requiring almost zero CPU during their idling seem avoidable, but I'm not sure if it's avoidable with App Engine.

这几乎就像一个长期调查",响应可能会保持打开状态,但什么也不做.

It's almost like a "long poll" where the response might be left open but doing nothing.

有没有一种方法可以在App Engine上做到这一点,而不必仅仅为实例小时支付疯狂的费用,还是我们最好迁移到Compute Engine或EC2?它会根据CPU负载自动扩展,还是仅基于未处理的总请求数或可能处于非活动状态的请求数进行扩展?—确实启用了 threadsafe .

Is there a way to do this on App Engine without just paying an insane amount for instance hours, or would we be better off moving to Compute Engine or EC2? Does it scale automatically based on CPU load, or is it based solely on open and perhaps inactive requests in total count? — threadsafe is indeed enabled.

推荐答案

实际上有两种方法可以解决(最重要的).

There are really two ways to go about this one (top of mind).

如果工作不需要与请求完全同时进行,那么这正是App Engine中的[任务队列]的目的.它们使您可以将工作放在队列中,并让另一个模块来处理工作.它们之所以很棒,是因为您可以分别扩展您的前端和后端流程.

If the work doesn't need to be exactly at the same time of the request, this is exactly what [task queues] in App Engine are for. They allow you to put a job on a queue, and have another module pick up the work. They're kind of great because you can separately scale your front end and back end processes.

如果那不起作用......

If that doesn't work....

App Engine Flexible 只是在运行GCE实例.成本结构完全不同,因为您始终在后台运行VM来处理您的请求.

Under the hood App Engine Flexible is just running GCE instances. The cost structure is entirely different, since you persistently have a VM running in the background serving your requests.

希望这会有所帮助!

这篇关于Google App Engine是否可以长时间运行但CPU任务少或轮询时间长?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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