Engineering

BullMQ vs Temporal vs AWS Step Functions: Architecting 72-Hour Payment Retries for Flaky Nigerian Bank APIs

O
Oluwaseun AlabiTechnical Director
November 15, 202611 min read
BullMQ vs Temporal vs AWS Step Functions: Architecting 72-Hour Payment Retries for Flaky Nigerian Bank APIs

Handling multi-day bank delays and unnotified transfer failures in Nigeria requires resilient job orchestration. We benchmark BullMQ, Temporal, and AWS Step Functions across infrastructure cost, state safety, and developer effort.

Building payment systems in Nigeria means accepting a uncomfortable truth: transaction status is rarely synchronous. A user initiates an NIP (NIBSS Instant Payments) transfer or card payout, the upstream processor returns a 202 Accepted or a generic 96 System Malfunction, and the money sits in financial limbo. Sometimes the destination bank credits the account in four seconds; other times, NIBSS clears the pending queue 48 hours later on a Sunday morning.

If your architecture relies on simple inline retries or short-lived setTimeout scripts, your database will corrupt under peak load. When handling millions of Naira across unstable banking switches, your workflow orchestrator must safely hold state for hours or days without dropping jobs during server deploys, memory spikes, or network partitions.

We evaluated three orchestration models across production engineering workloads at Neobot Tech: BullMQ (Redis-backed queueing), Temporal (event-sourced durable execution), and AWS Step Functions (managed cloud state machines). Here is how they perform when subjected to the chaotic reality of Nigerian payment infrastructure.

Architecture Overview & Head-to-Head Comparison

Each tool approaches state persistence and retry logic differently. BullMQ stores pending job definitions inside Redis Data Types (primarily Sorted Sets and Hashes). Step Functions maintains state across AWS-managed JSON state machines. Temporal records every single execution step as an immutable event stream in a relational or NoSQL store (PostgreSQL, Cassandra, or MySQL).

| Criteria | BullMQ (Redis) | Temporal (Go/TS Engine) | AWS Step Functions | | :--- | :--- | :--- | :--- | | Infrastructure Model | Self-hosted (Redis cluster + Node/Python workers) | Self-hosted or Temporal Cloud (Managed) | Fully Managed Serverless (AWS) | | Max Safe Workflow Lifetime | 12 to 24 Hours (limited by Redis RAM) | Indefinite (Months/Years) | 1 Year (Standard Workflows) | | Execution Cost (1M 3-day retries) | Low (~$20/mo Redis VPS) | Medium ($50–$150/mo self-hosted Postgres DB) | High ($25+ per million state transitions) | | State Durability on Node Crash | Vulnerable if Redis persistence (AOF/RDB) lags | Cryptographically Deterministic (Full Event Sourcing) | Guaranteed by AWS Control Plane | | Local Developer Experience (DX) | Excellent (Run local Redis container) | Moderate (Requires Temporal CLI / Docker Compose) | Poor (Requires LocalStack or mock sam-cli) | | UI / Observability Quality | Basic (Bull-Board dashboard) | World-Class (Full step timeline & stack traces) | Good (AWS Console Visual Workflow) |


Option 1: BullMQ — Fast, Familiar, but Dangerously Memory-Intensive

For Node.js and TypeScript shops, BullMQ is usually the default pick. It operates over Redis using Lua scripts to ensure atomic state transitions. If you need to poll Paystack, Flutterwave, or an Interswitch gateway every 15 minutes for 4 hours, BullMQ handles it with minimal overhead.

The Failure Mode Under Nigerian Banking Outages

Where BullMQ breaks down is multi-day state storage under heavy queue backlogs. When a major tier-1 bank in Nigeria experiences a extended switch outage (such as during core banking migrations), your system might queue hundreds of thousands of delayed jobs.

Because BullMQ retains job payloads and retry metadata directly inside Redis RAM, holding 500,000 active delayed jobs with exponential backoff schedules causes exponential RAM usage. If your server runs low on memory, Linux kernel OOM kills will target your worker nodes. We previously wrote about managing host memory limits in Tuning Vector Log Shipping for Unstable Networks: Stopping OOM Kills on 1GB VPS Nodes.

Here is a production-grade BullMQ worker pattern configured with exponential backoff and custom jitter specifically tuned for bank reconciliation retries:

typescript // payout-worker.ts import { Worker, Job } from 'bullmq'; import { redisConnection } from './redis-config'; interface ReconciliationPayload { transferRef: string; accountId: string; amountInKobo: number; initiatedAt: string; } export const payoutReconciliationWorker = new Worker<ReconciliationPayload>( 'payout-reconciliation-queue', async (job: Job<ReconciliationPayload>) => { const { transferRef, accountId } = job.data; const response = await fetchBankStatusFromNIBSS(transferRef); if (response.status === 'PENDING') { // Throwing an error causes BullMQ to trigger the backoff strategy throw new Error(`RETRY_REQUIRED: Transfer ${transferRef} still pending at bank switch.`); } if (response.status === 'SUCCESS') { await markAccountDebited(accountId, job.data.amountInKobo); return { status: 'SETTLED' }; } if (response.status === 'FAILED') { await reverseReservedFunds(accountId, job.data.amountInKobo); return { status: 'REVERSED' }; } }, { connection: redisConnection, concurrency: 10, settings: { backoffStrategy: (attemptsMade: number) => { // Custom backoff intervals in milliseconds: // Attempt 1: 5m | Attempt 2: 30m | Attempt 3: 2h | Attempt 4: 12h | Attempt 5: 24h const delays = [300000, 1800000, 7200000, 43200000, 86400000]; return delays[attemptsMade - 1] || 86400000; }, }, } );

Verdict on BullMQ

  • Best for: Short-lived retries (< 12 hours), high-throughput notifications, and lightweight background jobs.
  • Avoid if: You need strict compliance auditing, 72-hour+ persistent sleep timers, or multi-step saga rollbacks across microservices.

Option 2: Temporal — Deterministic, Event-Sourced Code for Complex Workflows

Temporal flips the task queue model on its head. Instead of writing isolated job handlers, you write standard TypeScript, Go, or Python code that looks synchronous, but execution state is persisted after every line of awaitable code.

If your API process crashes while waiting on a 48-hour sleep statement, Temporal reconstitutes the memory state on a completely different worker machine by replaying the event history log. The worker picks up on the exact line of code where it died.

Solving the 72-Hour Bank Reconciliation Saga

In Nigerian fintech, a transfer is not just an API call. It is a multi-step financial saga:

  1. Lock user funds in internal ledger.
  2. Submit transfer payload to processor switch.
  3. Poll status every 2 hours up to 72 hours.
  4. If bank confirms failure, automatically unlock funds.
  5. If bank status remains unresolved after 72 hours, automatically route to human compliance/ops dashboard.

Here is how that workflow looks in Temporal TypeScript SDK:

typescript // workflows/payout-reconciliation.ts import { proxyActivities, sleep, ApplicationFailure } from '@temporalio/workflow'; import type * as activities from '../activities/bank-activities'; const { queryBankStatus, reverseLedgerReservation, escalateToHumanOps } = proxyActivities<typeof activities>({ startToCloseTimeout: '45 seconds', retry: { initialInterval: '2 minutes', backoffCoefficient: 2, maximumInterval: '1 hour', maximumAttempts: 5, }, }); export async function reconcilePayoutWorkflow(transferRef: string, amountKobo: number, userId: string): Promise<string> { let status = 'PENDING'; let totalHoursWaited = 0; const MAX_WAIT_HOURS = 72; while (status === 'PENDING' && totalHoursWaited < MAX_WAIT_HOURS) { status = await queryBankStatus(transferRef); if (status === 'SUCCESS') { return 'COMPLETED'; } if (status === 'FAILED') { await reverseLedgerReservation(userId, amountKobo, transferRef); return 'REVERSED_TO_USER'; } // Temporal sleep consumes ZERO server RAM or DB connections while waiting await sleep('2 hours'); totalHoursWaited += 2; } // Bank is still silent after 72 hours. Escalate safely without losing context. await escalateToHumanOps(transferRef, userId, amountKobo); return 'ESCALATED_TO_COMPLIANCE'; }

The Infrastructure Cost Reality

Temporal requires a underlying database engine to store event histories. If you self-host Temporal Server, you need a PostgreSQL instance or Cassandra cluster. For high volume, writing every event transition to disk can bloat database size quickly. If you run your database on self-managed infrastructure, make sure to read our analysis on storage engines in ClickHouse vs TimescaleDB vs Native Postgres Partitioning: Querying 100M Payment Ledger Logs on a $40 VPS.

Verdict on Temporal

  • Best for: Core payment engines, complex multi-bank routing logic, automated refunds, and mission-critical financial workflows where dropping a single execution state causes balance sheet mismatches.
  • Avoid if: Your team is small, lacks DevOps maturity to run Temporal Server (or budget for Temporal Cloud), and only needs simple background emails.

Option 3: AWS Step Functions — Low Maintenance, High Lock-In

AWS Step Functions allows you to express state machines as JSON (Amazon States Language) or visually inside the AWS Console. Step Functions coordinates serverless compute (AWS Lambda), SQS, and API Gateway directly.

The Pricing Trap for High-Frequency Polling

Step Functions standard workflows allow executions to run for up to 1 year, making it immune to server reboots or memory constraints. However, its pricing model operates strictly on State Transitions ($0.025 per 1,000 state transitions).

If you have 50,000 pending transactions during an extended Interswitch outage, and your state machine loops through a Wait state and a Lambda Task state every 5 minutes for 3 days:

  • Transitions per transaction per day = (24 hours * 12 checks) * 2 states = 576 transitions.
  • 3 days = 1,728 transitions per job.
  • 50,000 failing transactions = 86,400,000 state transitions.
  • Cost for that outage alone: 86,400 * $0.025 = $2,160 USD.

For a Nigerian engineering team operating on Naira revenue, a $2,160 USD cloud bill for a single bank outage is an intolerable margin hit.

Neobot Engineering Standard

Every system deployed by Neobot Tech incorporates enterprise baseline practices. We continuously audit our database topologies, REST API query paths, and frontend modular bundles to prevent latency spikes and ensure top-tier security posture.

Tags:#Software Architecture#Nodejs#System Design#Fintech#DevOps

Discussion

Comments Coming Soon

We are currently migrating our discussion engine to a new real-time database schema. Check back shortly to join the conversation.