Multi-Service Deployment with Parallel Fan-Out
When you need to coordinate the same operation across multiple services or regions, fan-out with child workflows lets you run them in parallel and roll back all successful deployments if any single one fails. This pattern is common for multi-region deployments, multi-provider notifications, and batch operations that span service boundaries.
How it works
Three phases: build once, deploy wide, verify everything. The distinctive part is the failure policy — this fan-out is all-or-nothing. A fleet running two different versions is worse than a failed deploy, so any region failing (at deploy or at health check) rolls back every region that succeeded.
Example: deploying to three regions
1import {2 Workflow,3 Tasks,4 Task,5 WorkflowContext,6 createTaskRefs,7} from '@orcher/sdk';89@Tasks()10class DeployTasks {11 @Task()12 async buildPackage(config: AppConfig): Promise<string> {13 return await ciClient.build(config);14 }1516 @Task()17 async deployToRegion(input: DeployInput): Promise<string> {18 return await cloudClient.deploy(input.region, input.artifactId);19 }2021 @Task()22 async rollbackRegion(deploymentId: string): Promise<void> {23 await cloudClient.rollback(deploymentId);24 }2526 @Task()27 async runHealthCheck(deploymentId: string): Promise<HealthStatus> {28 return await cloudClient.healthCheck(deploymentId);29 }30}3132const tasks = createTaskRefs(DeployTasks);3334@Workflow({ name: 'multi_region_deploy', version: '1.0.0' })35class MultiRegionDeploy {36 async run(37 ctx: WorkflowContext,38 input: DeploymentInput,39 ): Promise<DeploymentResult> {40 // Build the artifact once41 const artifact = await ctx.executeTask(tasks.buildPackage, input.config);4243 // Deploy to all regions in parallel44 const regions = ['us-east-1', 'eu-west-1', 'ap-southeast-1'];45 const results = await Promise.allSettled(46 regions.map((region) =>47 ctx.executeTask(tasks.deployToRegion, { region, artifactId: artifact })48 ),49 );5051 // Collect successes, check for failures52 const deployments: Array<{ region: string; id: string }> = [];53 let failed = false;5455 results.forEach((result, i) => {56 if (result.status === 'fulfilled') {57 deployments.push({ region: regions[i], id: result.value });58 } else {59 failed = true;60 }61 });6263 // Rollback all successful deployments if any failed64 if (failed) {65 await Promise.all(66 deployments.map((d) => ctx.executeTask(tasks.rollbackRegion, d.id)),67 );68 throw new Error('Multi-region deployment failed');69 }7071 // Health check all regions72 for (const dep of deployments) {73 const health = await ctx.executeTask(tasks.runHealthCheck, dep.id);74 if (!health.isHealthy) {75 await Promise.all(76 deployments.map((d) => ctx.executeTask(tasks.rollbackRegion, d.id)),77 );78 throw new Error(`Health check failed in ${dep.region}`);79 }80 }8182 return { regions: deployments };83 }84}The fan-out pattern scales to any number of targets. Each parallel task is individually journaled, so if the process crashes after deploying to 2 of 3 regions, replay skips the completed deployments and continues with the remaining one.
Two fan-out failure policies
This is the same fan-out shape as parallel ETL with the opposite failure policy — choose by what a partial result means in your domain:
Independent units — data sources, notifications, tenants. One failure is recorded and the rest deliver value. Parallel ETL works this way.
Homogeneous targets that must agree — versions across regions, schema changes across shards. Any failure rolls back every success.
Design notes
- Deployed is not healthy. The deploy call succeeding only means the region accepted the artifact — the health-check phase is a second gate that can trigger the same full rollback. For a cheaper failure mode, verify one canary region before fanning out to the rest.
- Roll back the set, not the stack. These compensations are independent, so they run in parallel — unlike a saga's ordered reverse walk, where each step's undo may depend on the next. Use ordering only when compensations actually depend on each other.
- Rollback is durable too. Each
rollback_regionis a journaled task: a crash halfway through the rollback resumes it, exactly as in the saga's crash-mid-rollback walkthrough. - Promote regions to child workflows when deploys grow steps. Here each deploy is one atomic call, so plain tasks are right. When a per-region deploy becomes drain → deploy → warm → verify, give each region a child workflow with its own journal and failure boundary.
Next Steps
- Child Workflows for Service Composition — Compose services into reusable workflow units.
- Saga Pattern with Automatic Rollback — Handle multi-service transaction failures with compensating actions.
- Event Gates for Human Approvals — Pause workflows until external input arrives.
- Best Practices & Performance — Guidelines and benchmarks for distributed workflows.