For Node.js SaaS background jobs, use a durable queue to retry failed jobs and keep cron for periodic discovery or repair; use a dead-letter queue or equivalent terminal review state when attempts are exhausted. The deciding constraint is not the number of lines needed to schedule a callback, nor the appealing simplicity of a single cron expression. It is whether the team can account for every intended business effect after a process dies at an arbitrary instruction, after a database commit but before an acknowledgement, or after two workers receive logically identical work. A job record that says only “failed” cannot answer that question. It needs an identity for the intended operation, a durable attempt history, a next eligible time, and a terminal disposition that can be reviewed without guessing what the system was trying to do.

Short answer: a queue with bounded retries and a terminal review path is the safer default for continuous Node.js SaaS work with material side effects, while cron is a reasonable low-volume scanner when coarse timing and duplicate-safe work are explicit requirements.

An architecture decision record should begin with the failure boundary, because names such as “queue,” “scheduler,” and “retry” conceal different obligations. A delivery is an instruction to attempt an effect. A payment capture, ledger posting, entitlement change, or notification record is the effect. The instruction may arrive more than once; the effect must remain singular where the domain requires it. This is an exactly-once mindset built on at-least-once delivery, not a claim that the transport can grant exactly-once business outcomes.

That distinction keeps the design honest.

What should Node.js SaaS use for failed background jobs: cron, a queue, or a dead-letter queue?

The comparison is best made by asking who owns state. A durable queue normally represents work that is ready, in flight, acknowledged, or eligible for redelivery. A cron process only provides a wake-up; if it scans a jobs table, the application and database must represent eligibility, claims, leases, abandoned ownership, retry timing, and terminal disposition. Either approach still requires idempotency at the business write.

Decision boundary Queue-driven worker Cron scanning durable rows
Continuous arrivals and bursts Workers can receive work as it becomes available Scan frequency sets latency and can create bursts of its own
Retry eligibility Delivery delay or recorded retry schedule Indexed next_attempt_at plus a scanner
Worker loss Unacknowledged work can be redelivered An expired lease must make work claimable again
Terminal failures A separate terminal destination or state A terminal row or a separate review table
Main operating burden Delivery semantics, backlog age, replay controls Query contention, lease correctness, scanner ownership
Strong fit Prompt work, several consumers, important side effects Small volume, coarse cadence, harmless recomputation

RabbitMQ's consumer-acknowledgement model illustrates a useful general rule: receiving a message is not the same event as completing the business transaction. An acknowledgement tells the broker what happened to delivery; a database commit tells the system what happened to the effect. Publisher confirms are another boundary again. A design that collapses these facts into one boolean will eventually make reconciliation ambiguous.

For a SaaS system, “simplest” should mean the smallest design whose state transitions can be explained during an audit or incident review. The cheapest initial scheduler can become costly when the team must later add an eligibility index, atomic claims, fencing against late workers, tenant fairness, replay controls, metrics, and access controls around stored failure data. A queue is not free of those concerns, either. It relocates some of them into delivery semantics and operations.

The catch is that a queue is not suitable merely because it sounds more serious. For a nightly report, an expiration sweep, or a reconciliation scan that discovers missing work, cron plus a carefully indexed table may be the clearer system. Stick with that model when timing can be coarse, volume is genuinely small, duplicate generation is harmless or naturally idempotent, and a human review path meets the service objective. Once work arrives continuously, retries need promptness, or the job mutates money or access, the queue-shaped state machine becomes easier to defend.

Record invariants before choosing the timer

The critical invariants are compact, but they should be written before a worker exists. One stable idempotency key represents one intended operation and survives every retry. The worker records the effect and an audit event in the same transactional authority. It acknowledges delivery only after that transaction commits. Attempt history records a stable error class, attempt number, first-seen time, last-seen time, and the next eligible time without retaining credentials or unbounded payloads. Retention, access, and deletion must follow the organization's compliance policy; a dead-letter store is still operational data.

A delivery can be repeated after a successful commit if the acknowledgement is not observed. This is ordinary behavior, not evidence that the business write should run twice. The second execution must encounter the same business key and converge to the prior result. Conversely, a failure before commit must leave a state from which another attempt can safely proceed. The annoying interval is the one between durable effect and delivery acknowledgement, which is why an in-memory “already done” map has no place in this design.

Permanent validation failures should move to review immediately. Transient failures need bounded, delayed retry with jitter so correlated workers do not repeatedly apply pressure to the same downstream dependency. Unknown failures should be visible rather than retried indefinitely. A terminal item is evidence for a controlled decision, not a trash can: replay creates a new audited action linked to the original item and does not quietly erase its prior attempts.

Priority deserves similar caution. RabbitMQ documents that classic priority queues use resources for priority levels and recommends a small range. More importantly, priority does not repair an unsafe retry policy. Separate urgent customer-facing work from bulk maintenance only when their service objectives differ, then watch for starvation; a retry storm can otherwise crowd out fresh work.

The critical path: commit, then acknowledge

The worker below uses generic interfaces so the ordering is visible without turning the article into a product setup guide. A Node.js worker needs the same contract even though the example is Go: a durable transaction decides the business result, and acknowledgement is the final delivery action.

package recovery import ( "context" "errors" "time" ) var ErrAlreadyApplied = errors.New("operation already applied") type Job struct { ID string IdempotencyKey string Attempt int AmountMinor int64 } type Tx interface { ClaimKey(context.Context, string) error PostLedger(context.Context, int64) error AppendAudit(context.Context, string, int) error } type Store interface { WithTransaction(context.Context, func(Tx) error) error } type Delivery interface { Ack(context.Context) error RetryAt(context.Context, time.Time) error DeadLetter(context.Context, string) error } func Handle(ctx context.Context, store Store, delivery Delivery, job Job) error { err := store.WithTransaction(ctx, func(tx Tx) error { if err := tx.ClaimKey(ctx, job.IdempotencyKey); err != nil { return err } if err := tx.PostLedger(ctx, job.AmountMinor); err != nil { return err } return tx.AppendAudit(ctx, job.ID, job.Attempt) }) if errors.Is(err, ErrAlreadyApplied) || err == nil { return delivery.Ack(ctx) } if job.Attempt >= 5 { return delivery.DeadLetter(ctx, "attempt_limit") } delay := time.Duration(1<<min(job.Attempt, 6)) * time.Second return delivery.RetryAt(ctx, time.Now().Add(delay)) } 

The exact transaction technique depends on the database and delivery system. It may use a unique constraint for the idempotency key, a transactional outbox, or a state transition guarded by a version. The invariant does not change: the system must be able to distinguish “effect committed,” “effect not committed,” and “delivery acknowledgement pending.” Don't conflate them.

The code also exposes a decision that deserves design review: retry scheduling is itself a durable state transition. An in-process timer disappears with the worker. A reliable design stores either the next eligible attempt or an outbox event before reporting the job as recovered, then reconciles cases where transport state and application state disagree. This is where a cron scanner can still serve a queue-based system well: it can detect stranded records and emit a controlled repair instruction, rather than acting as the primary executor for every request.

Test the boundaries and operate the evidence

Tests should force the transitions that happy-path integration tests skip. Stop a worker before commit, after commit but before acknowledgement, during retry scheduling, and during movement to terminal review. Submit a duplicate instruction with the same business key but a different delivery ID. Advance time beyond a lease. Reissue a terminal item twice. The durable assertions are one financial effect, a complete attempt history, and a terminal reason that remains stable when a dashboard refreshes.

Short tests help.

Load tests need the failure traffic too. A retry policy amplifies load precisely when a downstream dependency is slow, so capacity planning must include the database, network clients, and any external authority touched by the job. Track ready depth, oldest eligible age, in-flight count, retry rate by error class, terminal arrivals, lease expirations, processing latency, and idempotency conflicts separately. A single failed-jobs counter confuses healthy bounded retry with terminal loss. Age can matter before count when one delayed settlement action is more consequential than many disposable notifications.

Deployment is part of the retry design. Consumers should drain before an incompatible message change, readers should tolerate the prior message version during a rolling deployment, and replay throughput should be capped so historic remediation does not overwhelm current work. Access to terminal data should be limited, payloads should be minimized, and audit retention should be reviewed against the applicable compliance obligations. Those are not administrative extras; they determine whether a recovery process is defensible.

The rejected option is therefore not “cron is bad.” It is “cron as a disguised, incomplete queue for consequential continuous work.” A periodic scan remains useful for reconciliation and discovery. The final choice follows the failure boundary, the required recovery time, and the cost of a duplicate business effect.

References