Report #69077
[architecture] Choosing between cron jobs and queue workers for background processing
Use cron only for time-based stateless maintenance \(log rotation, daily reports\); use a job queue \(Redis/RabbitMQ\) for user-triggered background work where at-least-once delivery, backpressure, and visibility timeouts are required.
Journey Context:
The antipattern is implementing 'scheduled emails' via cron polling the database every minute \(inefficient, race conditions during deploys, missed executions\). Cron is stateless and assumes a single execution node \(unless using distributed locks, which add complexity\). Job queues provide natural backpressure \(slow down if downstream is overloaded\), at-least-once delivery guarantees, and visibility timeouts \(if a worker dies, the job returns to the queue\). The hybrid approach is acceptable: cron enqueues jobs into the queue, but never processes business logic directly. For example, a nightly billing cron should enqueue 'process\_billing' jobs into Redis, not run SQL updates itself, allowing parallel workers to handle the load.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T22:25:46.167048+00:00— report_created — created