Best way to handle long running tasks

2,411 views
Skip to first unread message

Ahmet Faruk Acar

unread,
Jan 6, 2020, 8:19:56 AM1/6/20
to Google App Engine
Hi everyone,

We built a web application where we utilized firebase functions for lightweight works such as login, update profile etc.
and we deployed two functions to App Engine

Function 1: Downloading an audio/video file from firebase storage and converting it with ffmpeg and uploading converted version back to storage. 
But App Engine is terminating with a signal in the middle of download process (after ~40 seconds) if the file is larger (>500MB)

Function 2: Calling Google API (ASR) and waiting response (progress %) and writing this response to firestore until it's completed (100%).
This process may take between 1 min - 20 min depending on the file length. But here we get two different problems.
1. Either App Engine creates a new instance in the middle of API call process and kills current instance (since we set instances# to 1) even there is no concurrent requests.
I don't understand this behavior since this should not require intensive CPU or memory usage. App Engine gives following Info in logs:
This request caused a new process to be started for your application, and thus caused your application code to be loaded for the first time. This request may thus take longer and use more CPU than a typical request for your application
2. Or App Engine terminates due to idle_timeout even it is waiting async API response and writing it to db. 
It looks like when there is no incoming requests, App Engine is considering itself as idle and terminating after a while (~10 minutes)
Eventhough documentation says:
GCP Docs.PNG





We are new to GCP and App Engine, so maybe we are using wrong product (e.g. Compute Engine?) 
and we saw PubSub, Cloud Tasks etc. which looks like a solution for our case.
Thus I wonder what could be most elegant way to approach the problem and implement solution?
Any comment, feedback is appreciated.

Regards
A. Faruk Acar

App Engine app.yaml Configuration
runtimenodejs10
manual_scaling:
    instances1

David (Cloud Platform Support)

unread,
Jan 8, 2020, 3:45:19 PM1/8/20
to Google App Engine

When using AppEngine, it is better to use Cloud Tasks at the moment of performing long-running requests. As you mentioned, you could also use Compute Engine and there could be ways to integrate PubSub but if you are already in App Engine and you would like to stick to it, Cloud Tasks would be a good solution for you.


Konrad Garus

unread,
Jan 9, 2020, 9:45:59 AM1/9/20
to google-a...@googlegroups.com
I believe Cloud Tasks have a 10-minute timeout, correct?

If you need something longer, with Cloud Tasks you have to go for manual scaling - and give up on the fully managed, "just works" solution.

śr., 8 sty 2020 o 21:45 'David (Cloud Platform Support)' via Google App Engine <google-a...@googlegroups.com> napisał(a):

When using AppEngine, it is better to use Cloud Tasks at the moment of performing long-running requests. As you mentioned, you could also use Compute Engine and there could be ways to integrate PubSub but if you are already in App Engine and you would like to stick to it, Cloud Tasks would be a good solution for you.


--
You received this message because you are subscribed to the Google Groups "Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-appengi...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-appengine/fc1b5060-837f-470f-b799-204f6b781632%40googlegroups.com.


--
Konrad Garus

Olu

unread,
Jan 9, 2020, 3:18:49 PM1/9/20
to Google App Engine
the Default Timeouts that apply with Cloud Tasks actually depends on the scaling type of the service. As explained in this documentation[1-- even though the documentation points to App Engine tasks, the same applies with Cloud Tasks], 10 minutes default timeout applies for Automatic scaling standard apps in App Engine Standard environment. You can find more information about the default timeouts and deadlines on this PHP Client Library[2 -- See the section about the dispatch_deadline].

Cloud Tasks enables serverless execution of tasks via App Engine standard or flexible environments

Reply all
Reply to author
Forward
0 new messages