Skip to content
Visual explainer 2h 30m to learn 5 steps

Cloud Tasks, Eventarc, Workflows or Cloud Scheduler

Place a retryable job, an event fan-out and a multi-step orchestration in Cloud Tasks, Eventarc, Workflows or Cloud Scheduler.

By Invicly Tech, , in Google Cloud Engineering and Services. About 8 minutes to read.

Topic 17 of 32

In short

Four services cover most scheduling and coordination on Google Cloud. Cloud Tasks queues retryable jobs for a known target, and Eventarc routes events to a handler. Workflows runs several steps in order, and Cloud Scheduler starts something at a set time.

Think of it like this: Cloud Tasks is a to-do tray, Eventarc is a doorbell that tells the right person, Workflows is a checklist with a manager, and Cloud Scheduler is an alarm clock.

Explained simply

Once a system grows, you need ways to run work later, react to events and do steps in order. Google Cloud has four small services for this, and the skill is picking the right one.

Cloud Tasks is a queue of jobs. Your code adds a task that says call this URL with this data. Cloud Tasks sends it, retries it if it fails and respects a rate limit so a backend is not overwhelmed. You know exactly who will do the work.

Eventarc is for events. Something happens, such as a file arriving in a bucket, and Eventarc delivers an event to your handler, usually on Cloud Run. The source does not need to know who is listening.

Workflows runs a list of steps you write in YAML: call this API, wait, branch, retry, call the next one. Cloud Scheduler is the alarm clock that starts a job on a cron schedule, for example every morning at 06:00.

Press Play on a diagram to walk through it one step at a time.

CompareWhat each service is for
Cloud Tasks
  • You name the target
  • Rate limits and retries per queue
  • Delay a task to a later time
Eventarc
  • Reacts to events from Google services or Pub/Sub
  • Delivers CloudEvents to Cloud Run
  • Sender does not know receivers
Workflows
  • YAML steps with branches
  • Retries, waits and callbacks
  • Calls APIs and services in order
MapPick one by the question you are asking
What do I need?
  • Run this later, with retries
    • Cloud Tasks
  • React when something happens
    • Eventarc
    • Pub/Sub for custom events
  • Do five steps in order
    • Workflows
  • Do it every morning
    • Cloud Scheduler
FlowNightly report from Scheduler to result
  1. 1
    Cloud Scheduler

    0 2 * * *

  2. 2
    Workflows execution

    Starts the job

  3. 3
    Cloud Run job

    Builds the report

  4. 4
    Cloud Storage

    Report saved

  5. 5
    Pub/Sub message

    Tells others it is ready

In depth

Cloud Tasks: queues, rates and retries

A queue holds tasks and has settings for the maximum dispatch rate, the maximum concurrent dispatches and retries. Retry settings include maximum attempts and minimum and maximum backoff. Tasks can be scheduled for a later time, and a task name can help avoid creating the same task twice.

The target is an HTTP endpoint, such as Cloud Run. Use an OIDC token so the target can verify the caller. A response in the 2xx range means the task is done; anything else counts as a failure and triggers a retry.

  • You choose the target
  • Rate and concurrency limits protect the backend
  • Retries use backoff
  • Task names can deduplicate

Eventarc and Pub/Sub for fan-out

Eventarc connects event sources to destinations. Sources include many Google Cloud services and Pub/Sub topics. Events arrive in the CloudEvents format. A trigger filters events, for example only object creation in one bucket, and sends them to a Cloud Run service or another supported destination.

For your own application events, publish to a Pub/Sub topic and give each interested team a subscription. That is fan-out: one event, many independent receivers, none known to the sender.

MapFan-out from one event
order-created event
  • Billing service
    • creates invoice
  • Warehouse service
    • reserves stock
  • Analytics
    • loads a row into BigQuery

Workflows and Cloud Scheduler

A workflow is written in YAML or JSON. Steps can call HTTP endpoints and Google APIs, assign variables, branch on conditions, loop, wait, and retry or catch errors. Workflows keeps the state between steps, and an execution can run for a long time, so it can wait on a callback.

Cloud Scheduler uses cron syntax and a time zone. Its target can be an HTTP endpoint, a Pub/Sub topic or a workflow. Scheduler is at least once too, so make the target idempotent. Start a workflow from Scheduler for nightly multi-step jobs.

Learn it in 5 short steps

About 30m each. Track them with a timer in your plan.

  1. 1
    Queue retryable work with Cloud Tasks~30m
  2. 2
    Fan out events with Eventarc~30m
  3. 3
    Orchestrate steps with Workflows~30m
  4. 4
    Run on a schedule with Cloud Scheduler~30m
  5. 5
    Pick one per scenario~30m

Key points

  • Cloud Tasks suits work the caller wants done by one specific service, such as sending a receipt email, with control over rate and retries.
  • Pub/Sub and Eventarc suit one event with many possible listeners. The publisher does not know who reacts.
  • Workflows keeps state between steps, so it fits multi-step jobs where each step may fail or wait.
  • Cloud Scheduler uses cron syntax and a time zone. It only starts something, so pair it with an HTTP target, a topic or a workflow.
  • Every one of these is at least once. Handlers still need to be idempotent.

Key terms

Tap a card to flip it. 0/5 known

Examples

yaml
main:
  steps:
    - charge:
        try:
          call: http.post
          args:
            url: https://payments.example.com/charge
          result: paid
        retry: ${http.default_retry}
    - ship:
        call: http.post
        args:
          url: https://shipping.example.com/ship
    - done:
        return: ${paid.body}

A small workflow: charge, then ship, with a retry on the charge.

Create a queue and a scheduled call

Prerequisite: a test project and a Cloud Run service at a placeholder URL. Create a queue limited to 5 calls a second and a Scheduler job that runs daily. Evidence: the job shows a last attempt time. Cleanup: delete the queue and job.

bash
gcloud tasks queues create receipts --max-dispatches-per-second=5
gcloud scheduler jobs create http nightly-report \
  --location=europe-west2 \
  --schedule="0 2 * * *" --time-zone="Europe/London" \
  --uri=https://report-xyz.a.run.app/run \
  --oidc-service-account-email=sched@<project-id>.iam.gserviceaccount.com
gcloud scheduler jobs run nightly-report --location=europe-west2

Choose by scenario

Three requests arrive. Send a receipt email with at most 10 per second: Cloud Tasks. Tell billing, warehouse and analytics that an order was placed: a Pub/Sub topic with three subscriptions, or Eventarc for a Google source. Run charge, ship, notify in order with retries and a wait for a courier callback: Workflows. Run a clean-up every Sunday: Cloud Scheduler calling a Cloud Run job.

Quick reference

  • Cloud Tasks: known target, rate limits, retries, delayed tasks.
  • Pub/Sub or Eventarc: one event, many receivers.
  • Workflows: ordered steps, state, waits, error handling.
  • Cloud Scheduler: cron plus time zone, starts a target only.
  • Every service here is at least once; make handlers idempotent.
  • Use OIDC tokens so targets can verify the caller.

Common mistakes

  • Using Workflows for one simple call that a queue would handle.
  • Using Cloud Scheduler as a work queue by firing it every minute to poll.
  • Forgetting that retries repeat work, then charging a customer twice.

Quick quiz

Pick an answer to see if you're right and why.

Question 1

1You must send emails at no more than 10 per second with retries. Best fit?

Question 2

2What does Cloud Scheduler do by itself?

Question 3

3Three teams must react to one order event independently. Best fit?

Question 4

4A job has five dependent steps and waits for a callback. Best fit?

0/4 answered

Practice exercises

Try each one yourself first. Use the hint if you get stuck, then compare with the solution.

  1. Exercise 1easy

    Write a cron expression for 07:30 on weekdays.

  2. Exercise 2medium

    Write a two-step workflow that calls one endpoint, then another, using the first result.

  3. Exercise 3hard

    Design who owns retries for a nightly import that calls a flaky partner API.

Check yourself

Answer in your head, reveal, then be honest with yourself.

Feel confident about this topic?

Frequently asked questions

Cloud Tasks or Pub/Sub?
Use Cloud Tasks when the caller names the target and wants rate and retry control. Use Pub/Sub when many receivers may want the event and the sender should not know them.
Do I need Workflows for two steps?
Often not. A single service can call two APIs. Use Workflows when state, waits or error handling make a chain hard to follow.
Will a scheduled job ever run twice?
It can. Delivery is at least once, so design the target to be safe to repeat.

Go deeper

ShareXLinkedInWhatsApp