Home / Insights / Architecture and Modernization
Architecture and Modernization
Background Jobs and Workflow Engines: Choosing Between Queues, Temporal and Step Functions
Most applications start with a simple job queue and later discover they are hand-building retries, state tracking and timeouts. This guide helps you decide when a queue is enough, when a workflow engine pays for itself, and how to choose between the main options.
TopicsArchitecture and ModernizationWeb and SaaS Development
Key takeaways
- A job queue is the right tool for short, independent, idempotent tasks. Once a process has several dependent steps, waits for hours or days, or needs compensation on failure, a workflow engine usually costs less than the custom code you would otherwise write.
- Delivery guarantees differ. Standard queues such as Amazon SQS deliver at least once, so consumers must tolerate duplicates; Step Functions Standard workflows offer exactly-once step execution, while asynchronous Express workflows are at-least-once.
- Code-first engines (Temporal, Azure Durable Functions) rely on deterministic replay, which imposes real constraints on how developers write workflow code.
- Choose by process shape, hosting constraints and team skills, not by popularity: duration, step count, human waits, volume and portability decide the fit.
- Whatever you choose, make every side effect idempotent, set explicit timeouts and dead-letter handling, and give operations a way to see and repair stuck work.
On this page
- What is the difference between a background job and a workflow?
- How far can a well-designed job queue take you?
- What do workflow engines add, and how do the main options differ?
- How should you decide which approach fits?
- Which implementation patterns apply whatever you choose?
- What are the risks and costs?
- Checklist: before you build your next background process
- Frequently asked questions
- Sources and methodology
Sending emails, generating reports, processing uploads, syncing with a CRM, charging a card, calling an AI model: almost every product has work that should not happen inside a web request. The first solution is usually a queue and a worker. It works well until a process grows a fourth step, needs to wait two days for a customer to sign, or must undo a payment when a later step fails. At that point teams find themselves writing a homegrown workflow engine in database tables and cron jobs.
This article is for CTOs, architects and engineering leads deciding how to run background work in a cloud application. It compares plain queues with workflow engines, sets out a decision framework, covers implementation patterns that apply to any option, and lists the risks and costs.
The trade-offs below come from our cloud application development work, where choosing the wrong layer for background work is one of the most common sources of later rework.
What is the difference between a background job and a workflow?
The distinction is not about technology but about the shape of the work.
Background jobs
A job is a single unit of work that can be retried independently: resize this image, send this email, recalculate this score. Jobs are usually short, have no dependency on other jobs, and their state is simply pending, running, done or failed. Job queues (Amazon SQS, RabbitMQ, Redis-backed libraries such as BullMQ or Sidekiq, Celery in Python) handle this well.
Workflows
A workflow is a sequence of steps with dependencies and state that must survive failures: verify identity, then create an account, then provision a card, then wait for activation, then send a welcome pack, and reverse earlier steps if a later one fails permanently. Workflows may run for minutes, days or months, and someone usually needs to ask ‘where is this case up to?’
The warning signs you have outgrown a queue
- Jobs enqueue other jobs, and nobody can draw the full chain from the code.
- A status table tracks which step each record is on, with cron jobs sweeping for stuck items.
- Retries are implemented differently in each worker.
- Processes wait for humans (approvals, signatures) or external callbacks.
- Failure of a late step requires undoing earlier ones.
Action: list your five most important background processes and mark each as a job or a workflow using the criteria above. The mix tells you whether you need a workflow engine at all.
How far can a well-designed job queue take you?
Further than many teams expect, provided the basics are right.
Understand delivery semantics
Amazon’s documentation on the SQS visibility timeout is a good illustration. When a worker receives a message, it becomes invisible for the visibility timeout (30 seconds by default, up to 12 hours). If the worker does not delete it in time, the message reappears and another worker can process it. Standard queues deliver at least once and the documentation states there is no absolute guarantee against duplicates, so consumers must be idempotent.
Practices that keep queues reliable
- Idempotent handlers: record a business key or message ID with a conditional write so a duplicate is detected and skipped.
- Right-sized timeouts: set the visibility timeout to typical processing time and extend it with a heartbeat for long tasks, as AWS recommends.
- Dead-letter queues: move messages that fail repeatedly to a separate queue with alerting, rather than letting them cycle.
- Small messages: pass IDs, not large payloads; fetch the current state when processing.
- Ordering only where needed: FIFO queues order messages within a group, but an in-flight message blocks the rest of its group, which reduces throughput.
The same AWS page notes that extending the timeout does not lift the 12-hour ceiling, and suggests Step Functions or splitting the task for longer work. That is a useful boundary marker: once you are chaining and tracking many such tasks, you are building a workflow.
Action: audit existing workers for idempotency and dead-letter handling before adopting anything new. Many reliability problems blamed on queues are actually missing basics.
What do workflow engines add, and how do the main options differ?
A workflow engine persists the state of each running process, schedules steps, applies retry policies, handles timers and lets you query progress. The three options we are asked about most often take different approaches.
AWS Step Functions
Workflows are defined as state machines (in Amazon States Language, often designed visually) that call Lambda functions and many AWS services directly. According to AWS’s guide to choosing a workflow type, Standard workflows can run for up to one year, are priced per state transition and provide exactly-once execution of steps unless you configure retries; execution history is available for 90 days. Express workflows run for up to five minutes, are priced by number of executions, duration and memory, and are at-least-once when asynchronous and at-most-once when synchronous. AWS suggests Standard for non-idempotent actions such as payments, and Express for high-volume idempotent processing.
Temporal
Workflows are written as ordinary code in languages such as Go, Java, TypeScript and Python. Temporal’s documentation on Workflows describes durable execution: workflows can keep running for long periods despite infrastructure failures because the engine records an event history and recreates state by replaying the workflow code. Interactions with the outside world (API calls, database queries, LLM invocations) go in Activities, whose results are recorded and reused on replay. Temporal can be self-hosted or used as a managed cloud service, and it is not tied to one cloud provider.
Azure Durable Functions
An extension of Azure Functions in which orchestrator functions coordinate activity functions, with the runtime handling state, checkpoints, retries and recovery. Microsoft’s Durable Functions overview positions it for long-running stateful workflows in code, with common patterns including function chaining, fan-out and fan-in, asynchronous HTTP APIs, monitors and human interaction. Like Temporal, orchestrators are replayed, so their code must be deterministic.
| Criterion | Job queue | Step Functions | Temporal | Durable Functions |
|---|---|---|---|---|
| Best for | Short, independent tasks | AWS-centric orchestration of services and Lambdas | Complex, long-running logic in code, multi-cloud | Azure-centric workflows in code |
| Definition style | Worker code | State machine (JSON/YAML, visual designer) | General-purpose code | General-purpose code |
| Long waits and timers | Manual (delays, cron) | Yes, up to one year (Standard) | Yes, durable timers | Yes, durable timers |
| Step execution semantics | At least once (standard queues) | Exactly once (Standard); at least once (async Express) | Activities retried per policy; design for idempotency | Activities retried per policy; design for idempotency |
| Main constraint | You build state tracking | Logic in a DSL; AWS lock-in | Determinism rules; cluster or managed service to run | Determinism rules; Azure lock-in |
| Cost driver | Messages and worker compute | State transitions or execution time | Self-hosted infrastructure or managed service usage | Function execution and storage backend |
Action: shortlist at most two options and prototype the same real process in both, including a failure and a retry. A day of prototyping reveals more than a week of reading.
How should you decide which approach fits?
Work through these questions in order.
- Is it a job or a workflow? If all your important processes are short, independent jobs, a well-run queue is enough. Stop here.
- Where does the application run? If you are committed to AWS and most steps call AWS services, Step Functions integrates with the least glue. On Azure Functions, Durable Functions is the natural choice. If you are multi-cloud, on Kubernetes or want to avoid provider lock-in, Temporal is the stronger candidate.
- How complex is the logic? Branching, loops, dynamic fan-out and rich error handling are easier to express and test in code (Temporal, Durable Functions) than in a state machine definition. Simple linear service orchestration is often clearer in Step Functions.
- How long do processes run? Minutes favour Express workflows or queues; days to months need durable timers in a Standard workflow or a code-first engine.
- What volume and cost profile? Model your expected executions and steps against each pricing basis. Per-transition pricing can become significant for chatty workflows with many small steps.
- What can your team operate? A self-hosted Temporal cluster is a production system needing database, monitoring and upgrades. A managed option shifts that burden for a fee.
For example, a SaaS onboarding process with identity checks, contract signature waits of up to two weeks and provisioning across three systems would be an illustrative fit for a workflow engine, while its thumbnail generation and email sending would stay on a queue. Most products end up with both. If you are still deciding on compute, see our comparison of serverless and containers.
Action: write down your answers to these six questions in an architecture decision record before choosing, so the reasoning survives team changes.
Which implementation patterns apply whatever you choose?
Idempotent side effects
Every step that charges, emails, writes or calls an external API must be safe to repeat. Use idempotency keys with payment and messaging providers and conditional writes in your own database.
Explicit timeouts and retry policies
- Set a timeout on every step; an external call without one can hang a workflow indefinitely.
- Use exponential backoff with a maximum attempt count, and distinguish retryable errors (timeouts, rate limits) from permanent ones (validation failures).
Compensation for multi-step processes
When a late step fails permanently, earlier steps may need reversing: refund a charge, release reserved stock, deactivate an account. Model compensations explicitly as steps, not as ad hoc scripts.
Human and external waits
Approvals, signatures and partner callbacks should be modelled as signals or events the workflow waits for, with a timeout and an escalation path. Our guide to automating approval workflows covers thresholds, delegation and escalation.
Versioning running workflows
Long-running workflows will still be executing when you deploy new code. Code-first engines need explicit versioning so replay of old histories does not break; state machine engines usually pin a running execution to its definition. Plan for this from the first release.
Observability and repair
- Correlate every workflow with a business ID (order, customer, case) so support staff can find it.
- Expose status, current step and last error in an internal admin view.
- Provide safe operations to retry, skip or cancel a stuck execution, with an audit trail.
AI steps
LLM calls are slow, rate-limited and occasionally fail or return unusable output, which makes them good candidates for activities with retries, timeouts and validation. Treat model output as untrusted input to the next step.
Action: make idempotency, timeouts and an admin view part of the definition of done for every new background process.
What are the risks and costs?
- Over-engineering: adopting a workflow engine for a handful of simple jobs adds infrastructure and concepts the team must learn. Start with the processes that genuinely need it.
- Determinism mistakes: in replay-based engines, using the current time, random values or direct I/O in workflow code causes failures that surface only on replay. Code review checklists and the engines’ testing tools help.
- Lock-in: Step Functions and Durable Functions tie workflow definitions to a cloud provider. That is acceptable if you are committed, but it should be a conscious choice.
- Cost surprises: per-transition or per-action pricing grows with workflow granularity. Model costs with realistic volumes and step counts before committing.
- Operational load: self-hosting an engine means owning its database, scaling, upgrades and backups.
- Hidden state: moving process state into an engine can make it harder to report on. Emit business events or write summaries to your own database for analytics.
Checklist: before you build your next background process
- Classified as a job or a workflow, with the reasoning recorded.
- Delivery semantics of the chosen tool understood and documented.
- Every side effect idempotent, with keys or conditional writes.
- Timeouts set on every step; retry policy distinguishes retryable from permanent errors.
- Dead-letter or failed-execution handling with alerting and an owner.
- Compensating steps defined for any process that changes money, stock or access.
- Human and external waits modelled with timeouts and escalation.
- A versioning approach for long-running executions across deployments.
- Business IDs on every execution and an admin view to inspect, retry or cancel.
- Cost modelled at expected volume, including steps per execution.
Frequently asked questions
Do we need a workflow engine if we already use a message queue?
Not necessarily. If your background work is mostly short, independent, idempotent tasks, a queue with good retry and dead-letter handling is enough. Consider a workflow engine when processes have several dependent steps, long waits, human approvals or compensation on failure.
Is Temporal better than AWS Step Functions?
Neither is better in general. Step Functions integrates closely with AWS services and suits AWS-centric orchestration. Temporal expresses complex logic in ordinary code and is not tied to one cloud, but it has determinism rules and needs a cluster or managed service. Prototype the same process in both if you are unsure.
Can workflow engines guarantee a step never runs twice?
Step Functions Standard workflows provide exactly-once step execution unless you configure retries, but external systems can still see repeated calls if a step times out after the side effect happened. The safest approach in any engine is to make side effects idempotent.
How do we handle processes that wait days for a customer?
Use durable timers and external signals or callbacks, which all three engines discussed here support. Model the wait explicitly with a timeout and a follow-up action, such as a reminder or escalation, rather than polling a database with cron jobs.
Can PoliteTech help us choose and implement this?
Yes. We design and build cloud backends on AWS, Azure and Google Cloud, including serverless and container-based workers, workflow platforms and the monitoring around them. See our Cloud Application Development service for how we work.
Sources and methodology
Guidance reflects PoliteTech delivery experience. The external references below informed specific points in this article.
- AWS: Amazon SQS visibility timeout — accessed 9 November 2026. 30-second default and 12-hour maximum visibility timeout, at-least-once delivery, heartbeats, dead-letter queues and the suggestion to use Step Functions for longer work
- AWS: Choosing workflow type in Step Functions — accessed 9 November 2026. Standard versus Express workflows: one-year versus five-minute duration, pricing basis, 90-day history and exactly-once versus at-least-once or at-most-once semantics
- Temporal documentation: Workflows — accessed 9 November 2026. Durable execution, event history, deterministic replay and the role of Activities for external calls including LLM invocations
- Microsoft Learn: Durable Functions overview — accessed 9 November 2026. Orchestrator, activity and entity functions with runtime-managed state, checkpoints, retries and recovery, and deterministic orchestrator code
Related reading
Continue your research
Is your background work a job queue or a workflow waiting to happen?
Share your most important background processes and we will help you decide what each needs, from a tidy queue to a workflow engine.
