Report #13433
[architecture] Scheduled cron jobs vs message queues for background job processing
Use message queues \(SQS, RabbitMQ, Redis Streams\) for event-driven background work; reserve cron only for truly time-based triggers \(daily aggregations\). Never use cron to poll database tables for pending work \('cron polling anti-pattern'\); instead, enqueue jobs immediately when state changes occur.
Journey Context:
Cron polling \(SELECT \* FROM jobs WHERE status='pending' every minute\) creates resource waste \(99% empty polls\), race conditions \(two workers grabbing same job without atomic locking\), and processing latency \(average 30-second delay\). Message queues provide push-based immediate processing, natural load leveling \(buffer absorbs traffic spikes\), and built-in visibility timeout/acknowledgment patterns for reliability. Exception: Time-based logic \(send digest email at 9am user's local time\) requires cron, but the cron job should enqueue a queue job to perform the actual work, not execute business logic directly. AWS EventBridge schedules → SQS enqueue → Lambda/Worker is the preferred pattern over polling.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T18:45:39.651136+00:00— report_created — created