Cloud Tasks vs PubSub

197 views
Skip to first unread message

Lance Jabr

unread,
Apr 18, 2021, 9:17:06 AM4/18/21
to Google Cloud Developers
I'm looking for architecture advice for an application I'm building. The app renders videos in a container on Cloud Run. Renders can take 1-5 minutes. I need advice on the best way to trigger these containers and I have a couple questions:

1. If I trigger the container from a Cloud Function and send a response back to the function from my container before the video has completed rendering, will the container be shut down before rendering finishes because it is no longer processing an HTTP request? I don't want to leave the function running for the entire render because it would just be idling waiting for the container to finish. I'm not exactly sure how Cloud Run decides that a container is "done" but I assume it is when it sends the HTTP response, not when the GET handler finishes processing.

2. I understand I could alternatively use Cloud Tasks or a PubSub trigger to start the rendering process asynchronously. I'm wondering if there is a major difference between these options regarding pricing or functionality that would make one a better choice.

Overall it seems kind of convoluted to trigger a Cloud Function which triggers a Cloud Task which triggers a Cloud Run container, and also I have to be running App Engine to use Cloud Taks at all, so I'm wondering if I'm missing something.

Advice appreciated!
Lance

John Rodkey

unread,
Apr 19, 2021, 9:07:30 AM4/19/21
to Lance Jabr, Google Cloud Developers

--
You received this message because you are subscribed to the Google Groups "Google Cloud Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-cloud-d...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-cloud-dev/0829ddad-33cf-4d09-88ef-242e86a9af0bn%40googlegroups.com.

Kevin Hirsh (Google Cloud Platform Support)

unread,
Apr 19, 2021, 5:51:56 PM4/19/21
to Google Cloud Developers
Hello,

In regards to question 1), The Cloud Run container will have CPU allocated within the first 4 minutes of the instance's startup time as it listens for requests, so if the render job is completed within 4 minutes this would be fine. In the scenario that it takes more time, and your container does indeed send the response back to the function before rendering is complete and is not handling any requests at the time, there will be no CPU allocated, and therefore the render operation will not progress.

For option 2), it depends on if you wish to control the delivery of your asynchronous jobs, if you do not wish to manage them, Pub/Sub would be recommended, if you would, Cloud Tasks would be recommended. Cloud Tasks is also suitable for scheduling jobs to explicit endpoints, in which looks to be the case in this scenario.

Kind regards.
Reply all
Reply to author
Forward
0 new messages