Report #102447
[architecture] Should I use a cron job or a task queue for recurring or delayed background work?
Use cron only for truly time-based triggers \(e.g., 'run a report every night at 2am'\). Use a task queue for everything triggered by events, user actions, or backpressure—work that must run once, in order, reliably, and without skipping missed intervals.
Journey Context:
Cron is simple but brittle: if a host is down at the scheduled minute, the job is skipped unless you build locking and catch-up logic. Multiple instances risk duplicate runs. Queues give at-least-once execution, visibility timeouts, retries, and horizontal scaling. The classic anti-pattern is a cron that polls a table every minute to find new work—that's a queue pretending to be a cron and wastes DB load. Use cron for scheduling, queue for execution. Common mistake: using cron for high-frequency polling or assuming 'run every minute' is close enough to real-time.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-07-09T04:53:09.987463+00:00— report_created — created