Report #96680
[architecture] When to use a job queue instead of cron for recurring background tasks
Use cron only for idempotent, short, strictly time-based triggers \(e.g., 'run at midnight'\); use a queue \(SQS, RabbitMQ\) for reliability, retries, rate limiting, and when job duration may exceed interval or require horizontal scaling
Journey Context:
Developers often implement 'cron job that HTTP POSTs to an endpoint every minute' which fails silently on timeout, creates overlapping runs if the job takes >1 minute \(race conditions\), and loses data on crash. Cron is appropriate only for simple time-based triggers \(e.g., 'generate daily report at 2 AM'\). For anything requiring durability, use a message queue: jobs persist until ACKed, consumers scale horizontally, and dead-letter queues handle poison pills. Critical anti-pattern: 'polling database every 5 seconds for new rows' — use LISTEN/NOTIFY \(Postgres\) or Change Data Capture instead. AWS EventBridge Scheduler \(cron\) should trigger SQS, which then invokes Lambda, combining both patterns correctly; never cron-shuffle \(curl in crontab\) in production.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T20:51:47.411277+00:00— report_created — created