Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Best approach to enqueue long-running run jobs?

Hi! I have the following scenario:

Front-end -> Cloud Run Service on serverless mode.

Based on the user action, it will call a long running and parameterized process, which can take more than one hour to complete.

Important: I CAN'T have two of this process running at same time, for data conflict reasons. I have to enqueue these processes.

What is the best approach to do that on GCP?

2 1 968
1 REPLY 1

Hello @sidnei_becker,

Welcome to the Google Cloud Community!

To handle long-running, parameterized processes on GCP, you can use Cloud Tasks with Cloud Functions . Here's a simple workflow:

1. The front-end triggers your Cloud Run service.
2. The Cloud Run service adds the task with parameters to a Cloud Tasks queue.
3. Cloud Tasks automatically triggers your Cloud Function.
4. The Cloud Function executes the long-running process with the provided parameters.

Cloud Tasks is a managed service that queues and executes tasks asynchronously, with built-in retry capabilities.

For more details, you can check out the documentation for Cloud Tasks and the tutorial for Cloud Functions.