# Apache Airflow

> Build, schedule and operate pipelines with Apache Airflow: DAG files, operators, the TaskFlow API, connections, XComs, scheduling and production best...

Canonical: https://www.internhack.in/roadmaps/tracks/data-engineer/airflow
Last updated: 2026-11-28

Build, schedule and operate pipelines with Apache Airflow: DAG files, operators, the TaskFlow API, connections, XComs, scheduling and production best practices.

Intermediate · about 10 hours · difficulty 3/5

Learn first: [Orchestration Concepts](https://www.internhack.in/roadmaps/tracks/data-engineer/orchestration-concepts)

Apache Airflow is the most widely used orchestrator and appears in the majority of Indian data engineering job descriptions. Managed versions include AWS MWAA, Google Cloud Composer and Astronomer.

### Architecture

- **Scheduler** decides what should run; **executors** (Local, Celery, Kubernetes) run tasks; the **webserver or API server** provides the UI; a **metadata database** stores state.
- DAGs are **Python files** in a DAGs folder, parsed regularly.

### Writing DAGs

- Define a DAG with `schedule`, `start_date`, `catchup` and default `retries`.
- **Operators** do work: `BashOperator`, `PythonOperator`, provider operators for S3, BigQuery, Snowflake, Databricks, `KubernetesPodOperator`.
- The **TaskFlow API** (`@dag`, `@task` decorators) makes Python DAGs cleaner and passes small values between tasks via **XComs**.
- **Connections and variables** store credentials and config outside code (ideally backed by a secrets manager).
- **Templating** with `{{ ds }}` and other macros injects the logical date into commands and SQL.

### Running and operating

- Run locally with the official Docker Compose setup or the Astro CLI.
- Trigger runs, clear failed tasks, and run **backfills** from the CLI or UI.
- Use **pools** to limit concurrency against fragile sources.
- **Datasets or assets** let one DAG trigger when another updates a table.

### Best practices

- Keep top-level DAG code light; heavy imports and API calls at parse time slow the scheduler.
- Make every task idempotent and parameterised by the logical date.
- Do not pass large data through XComs; pass paths or table names.

### Pitfalls

- `catchup=True` with an old `start_date` launching hundreds of runs on deploy.
- Doing heavy pandas processing inside Airflow workers instead of delegating.

You are ready to move on when you can run Airflow in Docker, write a TaskFlow DAG that extracts, loads and triggers dbt for a logical date, and backfill a week of runs.

## Key concepts

- **Scheduler, executor, metadata DB**
- **DAG definition and schedules**
- **Operators and providers**
- **TaskFlow API**
- **XComs**
- **Connections and variables**
- **Jinja templating and ds**
- **Backfills and catchup**
- **Pools and concurrency**
- **MWAA and Cloud Composer**

## Other options for this step

- [Dagster](https://www.internhack.in/roadmaps/tracks/data-engineer/dagster): Orchestrate pipelines as software-defined assets with Dagster: assets, partitions, resources, sensors and built-in lineage and observability.
- [Prefect](https://www.internhack.in/roadmaps/tracks/data-engineer/prefect): Orchestrate Python workflows with Prefect: flows, tasks, retries, caching, deployments, work pools and the Prefect UI.

## Mini project

Run Airflow with Docker Compose. Build a DAG that pulls data from a public API for the logical date, writes Parquet to MinIO, loads it into Postgres or DuckDB, runs dbt build, and posts a failure alert. Backfill 7 days and screenshot the grid view.

## Check yourself

You deploy a DAG with start_date one year ago and catchup enabled. What happens, and how do you prevent it?

## Free resources

- [Apache Airflow documentation](https://airflow.apache.org/docs/apache-airflow/stable/index.html) (Apache Airflow)
- [Airflow best practices](https://airflow.apache.org/docs/apache-airflow/stable/best-practices.html) (Apache Airflow)
- [Data Engineering Zoomcamp](https://github.com/DataTalksClub/data-engineering-zoomcamp) (DataTalksClub)

Previous: [Orchestration Concepts](https://www.internhack.in/roadmaps/tracks/data-engineer/orchestration-concepts) · Next: [Dagster](https://www.internhack.in/roadmaps/tracks/data-engineer/dagster)

## More in Containers and Orchestration

- [Docker for Data Engineers](https://www.internhack.in/roadmaps/tracks/data-engineer/docker)
- [Orchestration Concepts](https://www.internhack.in/roadmaps/tracks/data-engineer/orchestration-concepts)
- [Apache Airflow](https://www.internhack.in/roadmaps/tracks/data-engineer/airflow)
- [Dagster](https://www.internhack.in/roadmaps/tracks/data-engineer/dagster)
- [Prefect](https://www.internhack.in/roadmaps/tracks/data-engineer/prefect)

## Related

- [Roadmaps](https://www.internhack.in/roadmaps)
- [Data Engineer Roadmap](https://www.internhack.in/roadmaps/tracks/data-engineer)
