Report #5169
[architecture] When to use job queues versus scheduled cron jobs for background processing
Use job queues \(Redis/RabbitMQ/SQS\) for event-driven work triggered by user actions \(emails, image processing, webhooks\) requiring variable timing or immediate execution. Use cron only for time-domain business logic \(daily reports, data cleanup\) where the schedule itself is the trigger, not a user event.
Journey Context:
The common anti-pattern is 'polling for work': using cron to query the database every minute for new jobs \('SELECT \* FROM jobs WHERE status = pending'\). This creates unnecessary database load, high latency \(average 30s delay\), race conditions, and complexity around horizontal scaling \(multiple cron instances need locking\). Job queues provide immediate processing \(push vs pull\), natural back-pressure handling, and built-in retry mechanisms. The hybrid approach: cron should enqueue jobs into the queue \(e.g., 'generate\_daily\_report' job scheduled for 2am\), allowing worker pools to process them with queue semantics rather than cron doing the work directly. This distinction matters because 'queue' implies at-least-once delivery with retries, while 'cron' implies exactly-once execution requirements that are hard to guarantee in distributed systems without complex locking.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T20:46:38.169076+00:00— report_created — created