'Can Google Cloud Run be used to run a continuously-listening Python script?

I'd like to run a Python script in the cloud. It would use Tweepy Streaming to continuously listen for Tweets containing certain keywords. So it needs to run uninterrupted, 24/7.

Would Google Cloud Run be suitable for this use case?

The Quotas and Limits page mentions that requests timeout after 60 minutes max, but I don't know exactly what this means.

Thank you.



Solution 1:[1]

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. 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.

Solution 2:[2]

"some background task not tied to an event or HTTP request" Isn't what the OP wants? Merely to listen for tweets 24/7? Detecting a tweet is an event and an HTTP request. Cloud Run and Cloud Functions can be triggered 24/7 via its URL endpoints.

In the Cloud Functions Page, if you scroll down there is a section called "Integration with third-party services and APIs".

I quote this section: "... capabilities such as sending a confirmation email after a successful Stripe payment or responding to Twilio text message events"

listening for tweets counts too. So it seems Google Cloud Functions/ Cloud Run can be used for the OP's use case.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Doug Stevenson
Solution 2 Inn0v8_m8