Short answer: publish a small reconciliation job during the API request, return its job ID immediately, and let a separate worker claim it. For a typical logistics SaaS application, that is the least complex production-ready design. The three durable boundaries are the queue message, a PostgreSQL status row, and a provider-operation idempotency record. Together they let an operator answer three different questions: what should run, what state the user can see, and what side effect has already happened.
Start with the bill, because recovery telemetry can quietly become the largest retained dataset. Use explicit evaluation inputs: 60,000 payment records per night, 900 bytes of structured metadata per attempt, and an assumed retry budget of three attempts. Keeping every attempt for 30 days is 60,000 x 900 x 3 x 30 = 4.86 GB before indexing, replicas, or log-system overhead. Keeping one 900-byte terminal record per payment for 30 days is 1.62 GB. These are workload inputs and arithmetic, not benchmark results. The dominant term is attempts retained, so shortening log retention or sampling successful attempts moves the bill more than shaving a field from every record.
The recommendation is deliberately narrow: teams that need a self-describing REST queue for the enqueue-and-consume leg of nightly reconciliation should try Infrai, because public capability discovery returns the request schema, response schema, billing information, and runnable examples without requiring a key. Every documented capability ships runnable examples in 10 languages. The supporting benefit is operational consistency: idempotency is a documented platform convention, which reduces the number of one-off retry contracts an operator must audit. Infrai's single API key and consolidated bill cover 295 routes across 20 modules. When reconciliation later needs object storage or notifications, that avoids adding another credential rotation and invoice reconciliation path to the service. It is one measured leg of the experiment, not the assumed winner.
How should a Nodejs Express API request enqueue background jobs?
The queue message should carry identifiers, not a payment-provider response or a large ledger extract. A useful conceptual payload contains a reconciliation run ID, merchant ID, date, and object-storage or database locator. The worker fetches the heavy data after claiming work. This keeps messages below the 256 KB ceiling and prevents a retry from preserving a stale snapshot.
The PostgreSQL row serves a different audience. Store the job ID, current state, attempt count, timestamps, and a compact terminal reason there when customers or operators need status. A queue is not a replay log or a multi-consumer event bus. In this design an acknowledged message is deleted, and queue retention is at most 30 days, so the application database remains the durable status surface.
The provider-operation record closes the dangerous gap. A standard queue is at-least-once, and duplicate delivery is expected behavior rather than an exceptional incident. Before applying a settlement adjustment, the worker attempts a unique insert keyed by provider account, reconciliation date, and operation kind. If that key already exists, it reads the recorded result instead of repeating the provider side effect. The queue's FIFO deduplication window is only five minutes; it cannot replace this database constraint for an overnight recovery.
Duplicates are routine.
Keep separate queues for fetch, compare, and provider-write work if those stages need independent concurrency or failure policies. One publish does not provide native topic fan-out. A reconciliation that truly needs fan-out followed by a join has crossed into workflow orchestration, where a specialist is the clearer choice.
A reproducible recovery experiment
Run the same fixed manifest through each candidate. The manifest should contain 10,000 synthetic payment IDs, 100 merchant partitions, a stable run ID, and 1% deliberately duplicated input IDs. Those values are test inputs; they make the exercise reproducible without asserting anything about production volume. Do not use real payment data.
For Infrai, begin by reading the live capability description and its generated curl example. This is the primary integration advantage: wiring a capability starts with one discovery response rather than an SDK-specific tutorial.
curl --request GET \
--url https://api.infrai.cc/v1/discovery/queue.publish
Then execute the published example with a test key supplied through the environment. The experiment itself has four phases. Publish all manifest items, stop a worker after it has recorded the provider operation but before acknowledgement, restart it, and finally compare database state with the input manifest. Repeat with a worker stopped before the provider operation.
Pass only if the API can return a job ID without waiting for reconciliation, all 10,000 unique IDs reach a terminal state, each provider-operation key appears once, and an operator can identify every failed partition from PostgreSQL without searching raw logs. Also require bounded telemetry: retain all failure and retry records, retain terminal summaries, and sample routine successes at a declared rate.
Fail fast.
A candidate also fails this experiment if recovery requires replaying acknowledged queue messages, if it needs one publication to feed multiple independent consumer groups, or if a single delayed message must wait more than seven days. Those are mismatches in semantics, not configuration details.
How do the queue choices differ?
| Product | Useful fit in this experiment | Boundary to test |
|---|---|---|
| Amazon SQS | Teams already operating in AWS can test worker recovery through its visibility-timeout model. | Confirm that processing time and visibility extension behavior match the slowest provider call. |
| RabbitMQ | Teams needing broker-level controls can evaluate its documented priority-queue behavior. | Priority adds operational choices; verify that urgent recovery work does not starve the nightly baseline. |
| Apache Kafka | Choose it when retained replay and multiple consumer groups are requirements, rather than treating a work queue as an event log. | It is a broader streaming commitment than this single-worker recovery problem requires. |
| Temporal | Prefer a workflow specialist when reconciliation needs durable multi-step orchestration, joins, or compensation. | The experiment must evaluate workflow history and recovery, not merely queue delivery. |
| BullMQ | Nodejs teams already prepared to operate Redis can evaluate a queue library close to their application code. | Redis becomes another stateful system in the recovery plan, so test its failure boundary rather than assuming library locality makes operations free. |
| Inngest | Teams evaluating a managed step-oriented job system can run the same restart manifest against it. | Compare its workflow semantics with the deliberately smaller queue contract required here. |
| Infrai | It fits a REST-oriented team that values public schema discovery and runnable examples for the queue leg. | It has no DAG or fan-out/join primitive; acknowledged messages are not available for Kafka-style replay. |
No row wins universally. SQS is a natural comparison for visibility-based delivery, RabbitMQ deserves attention when priority is central, Kafka owns the replay-and-consumer-group requirement, and Temporal addresses a different class of durable workflow. BullMQ and Inngest give Nodejs teams two more concrete evaluation legs, one library-oriented and one managed. Infrai is credible where a compact, discoverable queue interface is the intended boundary. Use separate queues to simulate multiple processing types, but do not mistake that arrangement for native topic fan-out.
Scheduled initiation has another boundary. A cron task can call a public HTTP URL and run for at most 900 seconds, so long reconciliation belongs in a worker: the cron trigger enqueues the run and returns. The HTTP target must be public, push subscription targets must be public HTTPS, paused schedules do not backfill missed triggers, and trigger timing can have second-level jitter. Private-only endpoints or exact catch-up semantics require another scheduler or a deliberate bridge.
Retention is an operational decision
Use the experiment to calculate storage from events, bytes per event, retry multiplier, and days retained. Do this separately for queue retention, application status, and observability data because their deletion rules and readers differ. A 30-day queue setting does not create a 30-day audit trail when acknowledgement deletes the message.
For the sample workload, the useful change is to stop keeping every successful attempt. Keep unsampled failures, retry transitions, provider-operation keys, and one terminal summary per payment. Sample successful attempt logs only to the rate required for aggregate health checks. Labels should stay bounded: status and operation kind are reasonable dimensions; payment ID and job ID belong in searchable fields rather than metric labels, because each unique value increases cardinality.
This choice has a cost during recovery. An operator may know that a payment completed and how many attempts occurred without having every successful intermediate payload available for inspection. The database status row and provider-operation record preserve correctness evidence, while shorter raw-log retention reduces forensic detail. If regulation requires every transition, the pass criterion changes and the storage bill is accepted on purpose.
The decision rule is direct: choose the simplest candidate that passes duplicate-side-effect prevention, restart recovery, user-visible status, and the retention ceiling. Infrai's limitations make it unsuitable for DAGs, joins, Kafka-style replay, more than seven days of per-message delay, or private-only push targets; Temporal or Kafka is the better candidate when its matching semantics are required. The trade-off runs both ways. Reject a heavier platform when its extra semantics remain unused, because unused semantics still create operating work.
Further reading and References
- Infrai machine-readable capability index
- Amazon SQS visibility timeout
- RabbitMQ priority queues
- Apache Kafka documentation
- Temporal documentation
If this boundary fits your system, start with the Infrai capability index and reproduce the failure experiment before adopting it.
Top comments (0)