简体   繁体   English

Google Cloud Run 能否用于运行连续侦听的 Python 脚本?

[英]Can Google Cloud Run be used to run a continuously-listening Python script?

I'd like to run a Python script in the cloud.我想在云中运行 Python 脚本。 It would use Tweepy Streaming to continuously listen for Tweets containing certain keywords.它将使用Tweepy Streaming持续监听包含特定关键字的推文。 So it needs to run uninterrupted, 24/7 .所以它需要24/7 不间断地运行。

Would Google Cloud Run be suitable for this use case? Google Cloud Run 是否适合这个用例?

The Quotas and Limits page mentions that requests timeout after 60 minutes max, but I don't know exactly what this means.配额和限制页面提到请求在最多 60 分钟后超时,但我不知道这到底是什么意思。

Thank you.谢谢你。

No, it would not be a good choice.不,这不会是一个好的选择。 Serverless infrastructure provided by products like Cloud Run and Cloud Functions is generally assumed to expand and contract server instances on demand, and server instances are never guaranteed a long uptime. Cloud Run 和 Cloud Functions 等产品提供的无服务器基础设施通常被假定为按需扩展和收缩服务器实例,并且服务器实例永远无法保证长时间正常运行。 If you absolutely require 24/7 uninterrupted operation of some background task not tied to an event or HTTP request, you should use a different cloud product, such as App Engine or Compute Engine.如果您绝对需要某些与事件或 HTTP 请求无关的后台任务的 24/7 不间断运行,则应使用不同的云产品,例如 App Engine 或 Compute Engine。

"some background task not tied to an event or HTTP request" Isn't what the OP wants? “一些后台任务与事件或 HTTP 请求无关”这不是 OP 想要的吗? Merely to listen for tweets 24/7?仅仅为了 24/7 全天候收听推文? Detecting a tweet is an event and an HTTP request.检测推文是一个事件和一个 HTTP 请求。 Cloud Run and Cloud Functions can be triggered 24/7 via its URL endpoints. Cloud Run 和 Cloud Functions 可以通过其 URL 端点全天候 24/7 触发。

In the Cloud Functions Page , if you scroll down there is a section called "Integration with third-party services and APIs".Cloud Functions 页面中,如果向下滚动,会出现一个名为“与第三方服务和 API 集成”的部分。

I quote this section: "... capabilities such as sending a confirmation email after a successful Stripe payment or responding to Twilio text message events"我引用这部分:“......功能,例如在 Stripe 付款成功后发送确认 email 或响应 Twilio 短信事件”

listening for tweets counts too.收听推文也很重要。 So it seems Google Cloud Functions/ Cloud Run can be used for the OP's use case.因此,Google Cloud Functions/Cloud Run 似乎可用于 OP 的用例。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM