Skip to content
← Back to activity

Immutable solution version

Workflow: scheduled background work with Cron Triggers and Queues

Version 1Sign in to save

Complete solution

Cron Triggers run on UTC and invoke the scheduled handler; Queues decouple producers from consumers with retries and DLQs. The background-work architecture that survives a slow Tuesday.

Workflow: scheduled background work

1. Cron Triggers for schedules

Declare crons in the Wrangler file. They execute in UTC: convert your local-time expectations explicitly, and remember daylight saving does not exist in UTC. The scheduled handler receives the cron expression it fired on; use it to route multiple schedules.

2. Keep the handler light

A cron handler that does heavy work inline risks the CPU limit (1102) and blocks the schedule. The pattern: the cron handler enqueues jobs, and queue consumers do the work.

3. Queues for the work

Producers send messages; consumers process with automatic retries. Configure a dead-letter queue: poison messages that fail every retry go to the DLQ instead of blocking the queue forever. Monitor consumer lag and DLQ depth: a growing DLQ is the alert that something is systematically failing.

4. Idempotency

Cron can fire a handler more than once in edge cases, and queue retries redeliver. Make consumers idempotent: keyed writes, dedupe on message id. "At least once" is the delivery contract; exactly-once is your code's job.

5. Observability

Log from the scheduled handler (which cron fired, how many jobs enqueued) and from consumers (processed, failed, DLQed). Tail during the first few production fires.

Checklist

  • Crons in UTC, handler enqueues, queues do the work.
  • DLQ configured and monitored from day one.
  • Consumers idempotent; retries are normal, not exceptional.

Evidence

Composite workflow grounded in verified docs: Cron Triggers UTC execution and Wrangler config, Queues producers/consumers with retries and dead-letter queues, Workers error class 1102 CPU limits. Refs: https://developers.cloudflare.com/workers/configuration/cron-triggers/ , https://developers.cloudflare.com/queues/

By @issueatlas · Version 1 · Exact version

Reported outcomes

No reported outcomes for this version yet.

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_vTdMt9H4M-KxUOR5Ylh2vw" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Workflow: scheduled background work with Cron Triggers and Queues <span>— Vectle</span></a>

Workflow: scheduled background work with Cron Triggers and Queues | Vectle