# Orchestration

Orchestration refers to the automated arrangement, coordination, and management of multiple systems, services, or tasks to carry out a defined workflow. In software architecture, orchestration typically involves a central controller that directs the sequence of operations, passes data between steps, handles errors, and manages retries -- as opposed to choreography, where each service independently reacts to events without centralized control.

## Orchestration vs. choreography

These two patterns represent different approaches to coordinating distributed services:

* **Orchestration**: A central orchestrator service defines the workflow and explicitly calls each participating service in order. The orchestrator knows the full sequence and manages the state of the overall process. Examples include AWS Step Functions, Azure Logic Apps, and Temporal.
* **Choreography**: Each service listens for events and performs its work independently. No single service knows the full workflow. Coordination happens through event buses or message queues. This approach is more decoupled but harder to debug and monitor.

In practice, many systems use a combination of both patterns. Orchestration is preferred when the workflow has complex branching logic, compensating transactions, or strict ordering requirements. Choreography works well for loosely coupled, event-driven systems where services can operate independently.

## Types of orchestration

Orchestration applies across several domains:

* **Service orchestration**: Coordinating calls across microservices to complete a business process, such as placing an order that involves inventory, payment, and shipping services.
* **Infrastructure orchestration**: Automating the provisioning and configuration of servers, networks, and storage using tools like Terraform, Pulumi, or Kubernetes.
* **CI/CD orchestration**: Managing build, test, and deployment pipelines through platforms like GitHub Actions, GitLab CI, or Jenkins.
* **Data pipeline orchestration**: Coordinating extract-transform-load (ETL) workflows using tools like Apache Airflow or Dagster.

## Orchestration and API gateways

An API gateway often participates in orchestrated workflows as the entry point that triggers the process. A client sends a request to the gateway, which routes it to the orchestrator or directly to the first service in the workflow. The gateway handles cross-cutting concerns -- authentication, input validation, CORS -- before the orchestration logic begins.

In some architectures, the gateway itself performs lightweight orchestration by routing a single client request to multiple backend services and aggregating the results. However, for complex workflows, a dedicated orchestration engine is a better fit.

Serverless API Gateway handles the routing and policy layer, directing requests to backend services that may themselves be orchestrated. Its path-based routing and variable mapping capabilities let you route different API endpoints to different orchestration backends, while the gateway consistently enforces authentication and access policies at the edge.

## Related documentation

* [Path Routing](/configuration/paths.md) - Route requests to orchestration services
* [Servers Configuration](/configuration/servers.md) - Define upstream services involved in orchestrated workflows
* [Variable Mapping](/configuration/variable-mapping.md) - Transform requests between the gateway and backend services


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.serverlessapigateway.com/glossary/o/orchestration.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
