- Category: B. Software Architecture
- English term: Orchestration and Choreography
- Related: Control Plane and Data Plane · Webhook and Polling · Watchdog Timer / Watchdog Process · Work Queue (Producer-Consumer Pattern) · A2A (Agent-to-Agent)
General Meaning
There are two contrasting approaches to coordinating multiple services or autonomous components to complete a workflow.
Orchestration relies on a central conductor (orchestrator) that tracks overall progress and issues explicit commands ('Service A next, then Service B'). It simplifies global visibility and exception handling, but the central coordinator can become a single point of failure or bottleneck. Choreography has no central conductor; each participant reacts autonomously to domain events like dancers following music. Services stay loosely coupled and scalable, though tracking end-to-end progress or spotting stalled workflows becomes harder.
Why It Matters
- Balancing coupling against global visibility: Pure centralization increases coupling, while pure event choreography obscures overall status; combining both fits complex workflows.
- Achieving both low latency and high reliability: Pairing immediate event-driven notifications with periodic central sweeps delivers fast reaction times without dropped tasks.
- Preserving agent autonomy: Defining clear contracts and boundaries allows workers to execute autonomously without micromanagement.
How the Site Factory Uses It
The Site Factory uses a hybrid architecture combining central Orchestration with event-driven Choreography. Every 15 minutes, the central dispatchers patrol.py and mac_gakari.py orchestrate the system by reclaiming stale tickets, enqueueing jobs, auto-merging PRs, and verifying production deployments.
At the same time, choreography handles real-time responsiveness: when GitHub sends a webhook to Cloudflare Workers, the doorbell (realtime_runner.py) rings and autonomous workers pull jobs from the queue—merging passing PRs within seconds of CI completion while keeping the 15-minute patrol.py sweep as a safety net. Between Studio 1 and Studio 2, limited A2A coordination passes tasks via step contracts and verified receipts without central micromanagement.
Caveats & Operational Rules
- Relying solely on choreography hides stalled tasks: In a pure event-driven setup, a crashed process or dropped network packet can leave a task stranded forever; the Site Factory always keeps its 15-minute central patrol as a catch-all safety net.
- Preventing duplicate execution is mandatory: When a real-time webhook and a periodic patrol spot the same task simultaneously, exclusive locks and generation numbers (fencing tokens) must prevent double execution.
- The orchestrator must never perform heavy work: If the conductor runs LLM inference or heavy data builds itself, global coordination halts; the Site Factory's
patrol.pystrictly dispatches work without invoking AI.
Related Terms
- Control Plane and Data Plane
- Webhook and Polling
- Watchdog Timer / Watchdog Process
- Work Queue (Producer-Consumer Pattern)
- A2A (Agent-to-Agent)
References
- Book: Mark Richards & Neal Ford, *Fundamentals of Software Architecture*, Chapter 12; Sam Newman, *Building Microservices, 2nd Edition*
Verified: 2026-11-08