How Airflow Executes Workflows – Scheduling vs Triggering
Think of Airflow as a smart traffic controller for your data pipelines. It decides **when tasks should start, in what order, and under what conditions. To manage this, Airflow supports two main execution methods: scheduling and triggering.
1. Scheduling Workflows​
Scheduling allows DAGs to run automatically at defined intervals, such as daily, hourly, or monthly.
Example Use Case: Calculate daily sales totals every morning at 6 AM
Input:
- DAG start date: 2025-12-15
- Schedule interval: @daily
Output: DAG runs automatically at 6 AM with tasks executing in order.
Python DAG Example:
from airflow import DAG
from airflow.operators.python import PythonOperator
from datetime import datetime
def calculate_sales():
print("Calculating daily sales totals...")
with DAG('daily_sales', start_date=datetime(2025, 12, 15), schedule_interval='@daily') as dag:
task = PythonOperator(
task_id='calculate_sales',
python_callable=calculate_sales
)
Execution Output:
2025-12-15 06:00:00 - Task calculate_sales started
Calculating daily sales totals...
2025-12-15 06:00:10 - Task calculate_sales succeeded
The DAG will automatically run every day at 6 AM without manual intervention.
2. Triggering Workflows​
Triggering allows DAGs to run on-demand, either manually or via external events, without waiting for the schedule.
Example Use Case: Re-run a failed data pipeline or run a DAG after a new file is uploaded.
Input: Trigger DAG manually via CLI or Web UI
Output: DAG starts immediately, executing all tasks in order
Manual Trigger Example (CLI):
airflow dags trigger daily_sales
Execution Output:
DagRun triggered: daily_sales __2025-12-15T12:00:00
Task calculate_sales started
Calculating daily sales totals...
Task calculate_sales succeeded
3. Task Execution Flow​
Airflow executes tasks based on dependencies defined in DAGs:
- Scheduler identifies tasks ready to run
- Executor assigns tasks to workers
- Tasks execute, optionally passing data via XCom
- Task state updated in Metastore
- Logs available in Webserver
Example Input/Output:
| Task | Input | Output |
|---|---|---|
| extract_data | API request: {"date": "2025-12-15"} | Raw sales JSON: {"sales": 400} |
| transform | Raw sales JSON | Aggregated JSON: {"total_sales": 400} |
| load_data | Aggregated JSON | Database updated successfully |
Final Thoughts​
Airflow’s execution model allows flexibility and control:
- Scheduling ensures repetitive workflows run automatically
- Triggering enables on-demand execution
- Combined with DAGs and task dependencies, it guarantees reliable, ordered, and auditable workflows
Understanding the difference helps optimize workflow efficiency and prevent unnecessary reruns.
Summary​
Apache Airflow executes workflows in two main ways:
- Scheduled Execution – Automated runs based on defined intervals
- Triggered Execution – Manual or event-based runs for flexibility
Tasks flow from Scheduler → Executor → Worker → Metastore → Webserver, ensuring consistent and reliable workflow execution.
Next Up: [Airflow UI Guide – DAGs, Graph View, Code View, Logs, Task Instances]