Why Workflow Orchestration: The Problem with Ad-Hoc Distributed Coordination
Why home-grown distributed coordination always breaks in production, and what workflow orchestration solves.
Why Workflow Orchestration: The Problem with Ad-Hoc Distributed Coordination
Why home-grown distributed coordination always breaks in production, and what workflow orchestration solves.
You have a multi-step business process: charge a customer, reserve inventory, send a confirmation email, update the CRM. Each step calls a different service. Each service can fail. The network can fail. Your own process can crash mid-way through. How do you make sure the whole thing eventually succeeds, or rolls back cleanly if it cannot?
Most teams start with the obvious approach: write some code that calls each service in sequence. Then they add retry loops. Then error handling. Then a database table to track progress. Then a cron job to resume stuck workflows. Six months later, that “simple” implementation is 2,000 lines of coordination logic tangled with business logic, and it still has edge cases nobody has found yet.
The Problem is Fundamentally Hard
Distributed coordination is not a solved problem you can duct-tape together with retries and a status flag. The challenges compound each other.
Partial failure: one of your steps fails after some steps have already succeeded. Do you retry from the beginning? Do you resume from where you left off? How do you know where you left off if your process crashed?
Timeout ambiguity: you called a payment service and got no response. Did it succeed and the response was lost? Did it fail before processing? You do not know, which makes retrying dangerous without idempotency.
Long-running processes: some workflows take hours, days, or weeks. Keeping a process alive for that long, handling machine restarts, deployments, and failures is not what application code is designed to do.
Compensation: when step 4 fails after steps 1–3 succeeded, you need to undo the side effects. But “undo” often means calling compensation APIs, not rolling back a database transaction.
These problems are not bugs you fix with more tests. They are inherent properties of distributed systems.
The Ad-Hoc Approaches and Why They Break
Before workflow orchestration existed as a category, teams built their own solutions. The patterns are familiar.
The Status Table Pattern
You create a workflow_runs table with columns for each step's status. A worker polls the table, picks up incomplete workflows, and advances them one step at a time.
# The "simple" approach: grows into a monster
def process_order(order_id: str) -> None:
run = db.get_or_create_workflow_run(order_id)
if run.step_charge == "pending":
result = payment_service.charge(order_id)
db.update(run, step_charge="done", charge_id=result.id)
if run.step_charge == "done" and run.step_inventory == "pending":
inventory_service.reserve(order_id)
db.update(run, step_inventory="done")
if run.step_inventory == "done" and run.step_email == "pending":
email_service.send_confirmation(order_id)
db.update(run, step_email="done")
This looks manageable until you add branching logic, error handling, retries with backoff, timeouts, cancellation, and observability. The state machine explodes. The business logic drowns in coordination plumbing.
The Message Queue Chain Pattern
Each step publishes a message that triggers the next step. Compensation events flow backward.
OrderPlaced -> charge-queue -> ChargeDone -> inventory-queue -> ...
The problem: the workflow is now spread across many consumers with no central view of progress. Debugging a stuck workflow means correlating logs across five services. Compensation requires publishing events that every step must listen for and handle correctly. The overall flow exists nowhere in code; it lives only in the collective behavior of all the message handlers.
Cron + Database
A cron job runs every minute, queries for stalled workflows, and attempts to advance them. Simple to build. Disastrous at scale. You end up with race conditions when multiple cron instances run simultaneously, no ordering guarantees, and a polling delay that makes your system feel sluggish.
What Workflow Orchestration Actually Provides
A workflow orchestration engine like Temporal solves these problems at the infrastructure level, not the application level. You write your workflow as ordinary code. The engine handles durability, retries, timeouts, and recovery.
# With Temporal: business logic, not coordination logic
@workflow.defn
class OrderWorkflow:
@workflow.run
async def run(self, order_id: str) -> str:
charge_id = await workflow.execute_activity(
charge_payment,
order_id,
start_to_close_timeout=timedelta(seconds=30),
)
await workflow.execute_activity(
reserve_inventory,
order_id,
start_to_close_timeout=timedelta(seconds=10),
)
await workflow.execute_activity(
send_confirmation,
order_id,
start_to_close_timeout=timedelta(seconds=5),
)
return charge_id
If the worker running this code crashes after reserve_inventory completes but before send_confirmation starts, Temporal replays the workflow from the beginning, skipping completed steps, and continues from where it left off. Your code does not have to handle this. The engine does.
The Core Value Proposition
Workflow orchestration buys you three things that are extremely expensive to build yourself.
Durability through event sourcing: every state transition is recorded as an immutable event. If a process crashes, the engine replays the event history to reconstruct the exact execution state. No polling, no status tables, no guessing.
Reliable retries and timeouts: you declare how you want retries to behave (backoff, max attempts, timeout) and the engine enforces it. You do not write retry loops.
Observability out of the box: because every step is recorded, you can see exactly where any workflow is in its execution, what the inputs and outputs were, and what errors occurred. Debugging becomes inspecting history, not correlating logs.
When You Need Workflow Orchestration
Not every process needs a workflow engine. A simple request/response API does not. A cron job that runs a query and sends a report does not. You need workflow orchestration when:
- The process spans multiple services or external APIs
- The process can run for minutes, hours, or days
- Partial failures require compensation or rollback
- You need to inspect the state of in-progress workflows
- The business requires audit trails of every step
If your “simple background job” has grown a status table, a retry mechanism, a dead-letter queue, and a Slack alert for stuck jobs, you already need workflow orchestration. You built a bad version of it.
Temporal’s Approach
Temporal is a workflow orchestration platform developed by the creators of Uber’s Cadence. It gives you a programming model where workflow code looks synchronous and sequential, but executes durably across time, failures, and restarts.
The key insight: Temporal turns your workflow code into a specification for what should happen. The server records what has happened. Workers execute steps. When the future diverges from the spec (due to failure), the system automatically reconciles.
You write code that reads like a script. The engine makes it fault-tolerant.
Key Takeaways
- Ad-hoc distributed coordination: status tables, queue chains, and cron jobs, always produces fragile systems that mix coordination with business logic
- Partial failure, timeout ambiguity, and long-running processes are inherent challenges that application code should not have to solve
- Workflow orchestration engines handle durability, retries, and recovery at the infrastructure level
- Temporal uses event sourcing to replay execution history, making workflows resumable after any failure
- Use workflow orchestration when processes span services, run for extended durations, or require compensation logic
메타데이터
- post_id
- fbec66321558
- slug
- why-workflow-orchestration-the-problem-with-ad-hoc-distributed-coordination-fbec66321558
- url
- https://medium.com/@hosseinnejati/why-workflow-orchestration-the-problem-with-ad-hoc-distributed-coordination-fbec66321558
- canonical_url
- https://medium.com/@hosseinnejati/why-workflow-orchestration-the-problem-with-ad-hoc-distributed-coordination-fbec66321558
- author_url
- https://medium.com/@hosseinnejati
- status
- ok
- fetched_at
- 2026-07-20 13:07:22