The Hidden Cost of Stateful Orchestration
SchemaBridge Team · 2026-02-02 · Distributed Systems, Immutable Infrastructure, Orchestration, Anti-Patterns, Reliability
Why your 'simple' internal tools might be your biggest reliability risk, and how applying Immutable Infrastructure patterns to application logic can save you.
In the world of microservices, we obsess over decoupling. We use queues, we adopt event-driven architectures, and we break monoliths. Yet, inside our orchestration engines, we often commit the cardinal sin of distributed systems: We write stateful loops.
At SchemaBridge, we recently overhauled our core system workflows. In doing so, we found ourselves confronting the same anti-patterns that plague many engineering organizations. This isn't just a story about our release notes; it's a case study in applying Immutable Infrastructure principles to the application layer.
The "Loop" Anti-Pattern
Consider the classic "Poller":
while not deployment.is_ready():
sleep(60)
check_status()
This code assumes a stable universe. It assumes the polling process will live forever. In reality, this is a Distributed Monolith artifact. As noted in the [AWS Builders' Library], relying on long-running synchronous state creates "zombie" processes and unpredictable failure modes.
The Solution: Recursive Chaining
We moved from an internal while loop to a Recursive Execution Model, similar to the Continuation Passing Style used in functional programming or the Saga Pattern in distributed transactions.
- Pattern: Step A does not "wait" for Step B. Step A spawns Step B as a new, independent workflow.
- Result: Zero "holding" state. If the orchestrator dies, the database state (Step B is queued) remains the source of truth.
Immutable Logic: Versioning use "content-addressable" identity
Versioning is famously hard. When you update a workflow definition, what happens to the executions already potentially running?
- The Anti-Pattern: "In-place updates." You deploy new code, and existing executions suddenly start behaving differently.
- The Industry Standard: Immutable Infrastructure. Just as we don't SSH into servers to patch them (we replace them), we shouldn't patch running workflow definitions.
We implemented Canonical DSL Hashing.
By hashing the Abstract Syntax Tree (AST) of our workflow logic, we treat every version as a unique, content-addressable entity. This aligns with strategies used by temporal.io and other modern engines: Execution Identity is tied to Code Identity.
Locking Down the "God Mode"
Finally, we addressed the security of internal tools. It is common to give internal "cleanup" scripts root access. This violates the Principle of Least Privilege.
We found that our own internal "Gradual Rollout" tool had the ability to clobber critical system IDs. We locked this down using a "Sudo" pattern where only cryptographically verified system actors can request specific logical IDs.
Conclusion
If your orchestration relies on sleep(), you are fighting the cloud.
By embracing Recursion, Immutability, and Strict Identity, we move from "Hope-based" orchestration to "Proof-based" orchestration.
Further Reading: