Search code examples
google-cloud-platformparallel-processinggoogle-cloud-run

How to determine which task is running in Google Cloud Run


I want to run parallel tasks in Google Cloud Run.

Each task does the same thing, but over 1/Nth of a dataset, and I want to run N tasks.

From my experience, when running processes in parallel, there is sometimes a way to tell what task number you're currently in, and out of how many. This is usually done through the environment. For example, CircleCI gives you CIRCLE_NODE_TOTAL and CIRCLE_NODE_INDEX found here.

Is there an equivalent in Google Cloud Run?


Solution

  • It looks like they are defined as: CLOUD_RUN_TASK_INDEX and CLOUD_RUN_TASK_COUNT, docs found here