Apache Airflow Explained — Quick Answer
Apache Airflow is an open-source workflow orchestration platform. You define workflows as Directed Acyclic Graphs (DAGs) in code, and Airflow schedules, monitors, and manages them. It is the de facto standard for batch data pipeline orchestration in 2026 — used by Airbnb, Google, Amazon, Uber, and most modern data teams. Alternatives include Prefect and Dagster, but Airflow remains the most widely adopted.
Core Airflow Concepts
| Concept | Description |
|---|---|
| DAG | Directed Acyclic Graph — a Python file defining the workflow |
| Task | A unit of work in a DAG |
| Operator | Template for a task (BashOperator, PythonOperator, etc.) |
| Sensor | A special operator that waits for an external condition (file, SQL row, API) |
| Scheduler | The Airflow component that triggers tasks at the right time |
| Executor | How tasks are run (Sequential, Local, Celery, Kubernetes) |
| Metadata DB | Stores DAG runs, task states, XComs (PostgreSQL/MySQL) |
Sample DAG
from airflow import DAG
from airflow.operators.bash import BashOperator
from airflow.operators.python import PythonOperator
from datetime import datetime
with def:
extract = BashOperator(
task_id='extract',
bash_command='python /scripts/extract.py',
)
transform = PythonOperator(
task_id='transform',
python_callable=transform_func,
)
load = BashOperator(
task_id='load',
bash_command='python /scripts/load.py',
)
extract >> transform >> load
Airflow Executors Compared
| Executor | How It Runs Tasks | Best For |
|---|---|---|
| SequentialExecutor | One task at a time, in the scheduler process | Dev/testing only |
| LocalExecutor | Parallel within the scheduler process | Small workloads, single-machine |
| CeleryExecutor | Distributed via Celery + Redis/RabbitMQ | Production, fixed cluster size |
| KubernetesExecutor | Each task runs in its own K8s pod | Production, dynamic scaling, isolation |
| CeleryKubernetesExecutor | Mix of Celery + K8s | Hybrid workloads |
KubernetesExecutor is increasingly the standard — each task runs in an isolated pod, with full dependency isolation.
Airflow vs Prefect vs Dagster
| Feature | Airflow | Prefect | Dagster |
|---|---|---|---|
| Adoption | Most adopted | Growing | Growing |
| Definition | Python DAGs | Python decorators | Software-defined assets |
| UI | Mature, comprehensive | Modern, clean | Modern, asset-focused |
| Dynamic DAGs | Possible (complex) | Native | Native |
| Testing | Manual | First-class | First-class |
| Ecosystem | Largest (providers) | Smaller | Smaller |
Airflow wins on ecosystem and maturity. Prefect and Dagster win on modern developer experience.
Top Airflow Use Cases
- ETL/ELT pipelines: Schedule Spark, dbt, warehouse loads.
- ML pipelines: Schedule training, evaluation, deployment.
- Data quality checks: Trigger Soda or Great Expectations tests.
- Reporting: Generate daily/weekly reports from warehouses.
- Cross-system orchestration: Coordinate AWS, GCP, Azure, and SaaS jobs.
Airflow Best Practices
- Use TaskFlow API (Airflow 2.0+): Cleaner decorator-based DAGs with @task.
- Set retries: retries=3, retry_delay=timedelta(minutes=5) on every task.
- Use SLA and alerting: Catch missed or slow tasks.
- Parameterise with Variables and Connections. Don't hardcode.
- Use the Astro CLI or managed services (Astronomer, MWAA, GCP Cloud Composer) for production.
- Test DAGs with pytest. Mock external dependencies.
Common Airflow Real-World Example — A Production Airflow DAG
Here is a realistic ETL DAG that runs every night:
- 00:00 — Ingest: SparkSubmitOperator runs a Spark job to ingest raw events from S3 into the warehouse.
- 02:00 — dbt run: BashOperator runs "dbt run --select staging+ marts+" to refresh staging and mart models.
- 03:00 — dbt test: BashOperator runs "dbt test" — fails the DAG if any data quality test fails.
- 03:30 — Soda checks: BashOperator runs Soda scans for additional quality validation.
- 04:00 — Refresh BI: HttpOperator triggers Looker/Power BI refresh via API.
- 04:30 — Notify: SlackOperator posts a success message to the data engineering channel.
This DAG runs on KubernetesExecutor — each task runs in an isolated pod with the right dependencies.
Avoid these traps when building Airflow DAGs:
- Hardcoding values in DAGs: Use Variables and Connections for any value that might change.
- No retries: Every task should have retries=3 with a meaningful retry_delay. Transient failures are normal.
- Long-running tasks: Tasks running more than 1 hour should be split or moved to Spark. Airflow's scheduler has timeout limits.
- No testing: Use pytest + airflow.models.DagBag to test DAGs in CI. Broken DAGs should fail the build.
- LocalExecutor in production: LocalExecutor runs tasks in the scheduler process. Use CeleryExecutor or KubernetesExecutor for production.
Quick Reference — Cheatsheet
- DAGs are Python files — no cycles allowed.
- Use TaskFlow API (Airflow 2.0+) for cleaner decorator-based DAGs.
- Set retries=3, retry_delay=5min on every task.
- KubernetesExecutor is the modern choice — each task = isolated pod.
- Always use managed Airflow (Astronomer, MWAA, Composer) for production.
Airflow Quick-Wins
Apply these patterns for production Airflow deployments:
- Use Pools for resource constraints: If multiple tasks hit the same API or database, use a Pool to limit concurrency.
- Set SLA on every DAG: sla_miss_callback alerts the team if a task exceeds the expected duration.
- Use XCom sparingly: XCom is fine for small metadata but not for large data. Use external storage (S3) for large payloads.
- Schedule with cron expressions: "0 2 * * *" runs at 2 AM daily. Use the Airflow UI to test cron strings.
- Enable task-level logging: Set AIRFLOW__LOGGING__REMOTE_LOGGING=True to ship logs to S3/GCS for long-term retention.
Frequently Asked Questions
What is Apache Airflow?
An open-source workflow orchestration platform. Workflows are defined as Python DAGs.
What is a DAG in Airflow?
A Python file defining a workflow — tasks + dependencies. No cycles allowed.
What is an Operator in Airflow?
A template for a task. BashOperator (shell), PythonOperator (Python), PostgresOperator (SQL), SparkSubmitOperator (Spark).
What Airflow executors are available?
Sequential, Local, Celery, Kubernetes, CeleryKubernetes. Production uses Celery or Kubernetes.
Is Airflow a streaming engine?
No — Airflow is batch. For streaming, use Flink, Spark Streaming, or Kafka Streams.
How does Airflow compare to Prefect or Dagster?
Airflow: most adopted, largest ecosystem. Prefect: cleaner developer experience. Dagster: software-defined assets.






