{"id":"workflow-orchestration-patterns","name":"workflow-orchestration-patterns","summary":"分散システム向けにTemporalを用いた持続的なワークフローを設計しましょう。ワークフローとアクティビティの分離、サガパターン、状態管理、決定性制約を扱っています。","body":"# Workflow Orchestration Patterns\n\nMaster workflow orchestration architecture with Temporal, covering fundamental design decisions, resilience patterns, and best practices for building reliable distributed systems.\n\n## When to Use Workflow Orchestration\n\n### Ideal Use Cases (Source: docs.temporal.io)\n\n- **Multi-step processes** spanning machines/services/databases\n- **Distributed transactions** requiring all-or-nothing semantics\n- **Long-running workflows** (hours to years) with automatic state persistence\n- **Failure recovery** that must resume from last successful step\n- **Business processes**: bookings, orders, campaigns, approvals\n- **Entity lifecycle management**: inventory tracking, account management, cart workflows\n- **Infrastructure automation**: CI/CD pipelines, provisioning, deployments\n- **Human-in-the-loop** systems requiring timeouts and escalations\n\n### When NOT to Use\n\n- Simple CRUD operations (use direct API calls)\n- Pure data processing pipelines (use Airflow, batch processing)\n- Stateless request/response (use standard APIs)\n- Real-time streaming (use Kafka, event processors)\n\n## Detailed patterns and worked examples\n\nDetailed pattern documentation lives in `references/details.md`. Read that file when the navigation tier above is insufficient.\n\n## Best Practices\n\n### Workflow Design\n\n1. **Keep workflows focused** - Single responsibility per workflow\n2. **Small workflows** - Use child workflows for scalability\n3. **Clear boundaries** - Workflow orchestrates, activities execute\n4. **Test locally** - Use time-skipping test environment\n\n### Activity Design\n\n1. **Idempotent operations** - Safe to retry\n2. **Short-lived** - Seconds to minutes, not hours\n3. **Timeout configuration** - Always set timeouts\n4. **Heartbeat for long tasks** - Report progress\n5. **Error handling** - Distinguish retryable vs non-retryable\n\n### Common Pitfalls\n\n**Workflow Violations**:\n\n- Using `datetime.now()` instead of `workflow.now()`\n- Threading or async operations in workflow code\n- Calling external APIs directly from workflow\n- Non-deterministic logic in workflows\n\n**Activity Mistakes**:\n\n- Non-idempotent operations (can't handle retries)\n- Missing timeouts (activities run forever)\n- No error classification (retry validation errors)\n- Ignoring payload limits (2MB per argument)\n\n### Operational Considerations\n\n**Monitoring**:\n\n- Workflow execution duration\n- Activity failure rates\n- Retry attempts and backoff\n- Pending workflow counts\n\n**Scalability**:\n\n- Horizontal scaling with workers\n- Task queue partitioning\n- Child workflow decomposition\n- Activity batching when appropriate\n\n## Additional Resources\n\n**Official Documentation**:\n\n- Temporal Core Concepts: docs.temporal.io/workflows\n- Workflow Patterns: docs.temporal.io/evaluate/use-cases-design-patterns\n- Best Practices: docs.temporal.io/develop/best-practices\n- Saga Pattern: temporal.io/blog/saga-pattern-made-easy\n\n**Key Principles**:\n\n1. Workflows = orchestration, Activities = external calls\n2. Determinism is non-negotiable for workflows\n3. Idempotency is critical for activities\n4. State preservation is automatic\n5. Design for failure and recovery","author":"@wshobson","ownerProfile":null,"authorContacts":null,"sourceUrl":"https://github.com/wshobson/agents/tree/main/plugins/backend-development/skills/workflow-orchestration-patterns","license":"MIT","category":"document","lang":"en","tokens":659,"stars":0,"calls30d":1,"claimed":false,"visibility":"public","origin":"crawler","version":"0.1.0","createdAt":"2026-08-22","updatedAt":"2026-08-22","files":[{"path":"references/details.md","size":5933,"sha256":"f904309ab60916d3e6943a2c35ffeadc48ddfa6a3defdd8da5472926ba8887cb"}],"requires":{"mcp":[],"tools":[]},"safety":{"flags":[],"scannedAt":"2026-08-22","hasScripts":false,"networkEndpoints":[]}}