Workflow Orchestration Patterns

Workflow Orchestration Patterns

Teaches an AI agent to design durable Temporal workflows for distributed systems, separating workflows from activities and applying sagas and determinism rules.

Skill files2 files

references/

SKILL.md99 lines
1
---
2
name: workflow-orchestration-patterns
3
description: Design durable workflows with Temporal for distributed systems. Covers workflow vs activity separation, saga patterns, state management, and determinism constraints. Use when building long-running processes, distributed transactions, or microservice orchestration.
4
---
5
6
# Workflow Orchestration Patterns
7
8
Master workflow orchestration architecture with Temporal, covering fundamental design decisions, resilience patterns, and best practices for building reliable distributed systems.
9
10
## When to Use Workflow Orchestration
11
12
### Ideal Use Cases (Source: docs.temporal.io)
13
14
- **Multi-step processes** spanning machines/services/databases
15
- **Distributed transactions** requiring all-or-nothing semantics
16
- **Long-running workflows** (hours to years) with automatic state persistence
17
- **Failure recovery** that must resume from last successful step
18
- **Business processes**: bookings, orders, campaigns, approvals
19
- **Entity lifecycle management**: inventory tracking, account management, cart workflows
20
- **Infrastructure automation**: CI/CD pipelines, provisioning, deployments
21
- **Human-in-the-loop** systems requiring timeouts and escalations
22
23
### When NOT to Use
24
25
- Simple CRUD operations (use direct API calls)
26
- Pure data processing pipelines (use Airflow, batch processing)
27
- Stateless request/response (use standard APIs)
28
- Real-time streaming (use Kafka, event processors)
29
30
## Detailed patterns and worked examples
31
32
Detailed pattern documentation lives in `references/details.md`. Read that file when the navigation tier above is insufficient.
33
34
## Best Practices
35
36
### Workflow Design
37
38
1. **Keep workflows focused** - Single responsibility per workflow
39
2. **Small workflows** - Use child workflows for scalability
40
3. **Clear boundaries** - Workflow orchestrates, activities execute
41
4. **Test locally** - Use time-skipping test environment
42
43
### Activity Design
44
45
1. **Idempotent operations** - Safe to retry
46
2. **Short-lived** - Seconds to minutes, not hours
47
3. **Timeout configuration** - Always set timeouts
48
4. **Heartbeat for long tasks** - Report progress
49
5. **Error handling** - Distinguish retryable vs non-retryable
50
51
### Common Pitfalls
52
53
**Workflow Violations**:
54
55
- Using `datetime.now()` instead of `workflow.now()`
56
- Threading or async operations in workflow code
57
- Calling external APIs directly from workflow
58
- Non-deterministic logic in workflows
59
60
**Activity Mistakes**:
61
62
- Non-idempotent operations (can't handle retries)
63
- Missing timeouts (activities run forever)
64
- No error classification (retry validation errors)
65
- Ignoring payload limits (2MB per argument)
66
67
### Operational Considerations
68
69
**Monitoring**:
70
71
- Workflow execution duration
72
- Activity failure rates
73
- Retry attempts and backoff
74
- Pending workflow counts
75
76
**Scalability**:
77
78
- Horizontal scaling with workers
79
- Task queue partitioning
80
- Child workflow decomposition
81
- Activity batching when appropriate
82
83
## Additional Resources
84
85
**Official Documentation**:
86
87
- Temporal Core Concepts: docs.temporal.io/workflows
88
- Workflow Patterns: docs.temporal.io/evaluate/use-cases-design-patterns
89
- Best Practices: docs.temporal.io/develop/best-practices
90
- Saga Pattern: temporal.io/blog/saga-pattern-made-easy
91
92
**Key Principles**:
93
94
1. Workflows = orchestration, Activities = external calls
95
2. Determinism is non-negotiable for workflows
96
3. Idempotency is critical for activities
97
4. State preservation is automatic
98
5. Design for failure and recovery
99

© Seth Hobson · MIT · source · posted by @OpenSourceBuffGuy on promptparty.com

@OpenSourceBuffGuy

I find openly licensed prompts and post them here.

0 followers · 11,963 prompts

More by @OpenSourceBuffGuy

See all
Werewolf hero clashes with jungle behemoth prompt image

Werewolf hero clashes with jungle behemoth

Directs a 30-second photorealistic creature-action film in which a hero turns into a werewolf and fights a moss-armored jungle behemoth, with character locks and timed beats.

video-prompt, action, creatures, fantasy-world, character-consistency, timed-beats, multi-shot, transformation, visual-effects, slow-motion, cinematic, photorealistic, forest, rain, dramatic-lighting, seedance, camera-movement, tracking-shot, long-form, structured-output, guardrails, martial-arts, film-score, reference-to-video

Ancient Civilization Miniature Diorama prompt image

Ancient Civilization Miniature Diorama

Draws a realistic miniature diorama of an ancient civilization's monuments under construction, set on blueprints atop a wooden drafting table.

image-prompt, gpt-image, miniature, photorealistic, architecture, history, blueprint, 3d-render, cinematic, natural-light, vertical-format, placeholders, long-form, construction, still-life, bokeh, architectural-rendering, for-artists, concept-art, fantasy-world

Error Handling Patterns prompt image

Error Handling Patterns

Teaches an AI agent resilient error handling across languages: exceptions versus Result types, propagation, retries, circuit breakers and graceful degradation.

agent-skill, best-practices, coding, backend, api, debugging, design-patterns, distributed-systems, clean-code, code, code-generation, software-architecture, troubleshooting, for-developers, advanced, long-form, cheat-sheet, guardrails, observability, refactoring, site-reliability, microservices, error-handling

Reviews

Loading reviews…

Discussion

Loading comments…