Data Engineering · Module 14
Orchestration with Airflow
- Lessons
- 10
- Free
- 0
- Reading
- ~3 h
Your progress
0 / 10 lessons done
Sign in to trackLessons
- Orchestration: DAGs, tasks and dependenciesEvery data team runs dozens of steps a night that must happen in a set order. Whether a late or failed step costs one rerun or a wrong number in front of leadership depends on the dependencies you declare.
- Airflow architecture: scheduler, workers and metadataWhen a night’s pipeline stalls, the first question is which part of Airflow stopped. Knowing what the scheduler, the workers and the metadata database each hold tells you where to look, what a restart loses, and what to run twice.
- Writing Airflow DAGs: operators and sensorsMost nightly pipelines spend more time waiting for other teams’ data than doing work. How a task waits decides whether a late file is included, how many workers sit idle, and whether a wait ends in a clear state.
- Schedules, catchup and data intervalsEvery scheduled pipeline has to know which hours or days of data it owns. When a run gets that wrong, it usually succeeds anyway, and the report it feeds is quietly empty or a day off.
- Backfills: rerunning history safelyEvery bug fix, new table and outage ends with the same job: put the past right. Done carelessly, a rerun of history repeats the bug, burns a day of API quota or delays the morning report.
- Retries, timeouts and deadline alerts in AirflowRetries that come too fast wake someone for an outage that would have passed. Retries that come too slowly, or never stop, make the report late. These settings decide which.
- Passing data between tasksEvery pipeline hands something from one step to the next. Hand over the wrong thing and the orchestrator’s own database fills with your data, which slows every DAG on the deployment.
- Assets and event-driven scheduling in AirflowA DAG that starts at a fixed hour trusts that another DAG finished first. When it hasn’t, the run succeeds on half the data and nobody hears. Assets let the data’s arrival start the work.
- Dagster, Prefect and managed orchestratorsRunning an orchestrator costs hours that never show on a cloud bill. Renting one, or switching engines, costs money, a rewrite or a version step back. Knowing which cost you are trading saves a migration you didn’t need.
- Design: orchestrating a daily reporting pipelineMost data teams own one DAG that a business reads every morning. Each Airflow setting can be right on its own and the report still be late, so the night has to be designed as a whole, backwards from the reader’s clock.
Practise with
No tools or paper guides for this module yet.
Terms this module teaches 45
Open glossaryAirflow API server
The Airflow 3 process that serves the UI and REST API and receives state updates and heartbeats from running tasks.
Airflow metadata database
The database, usually PostgreSQL or MySQL, where Airflow stores parsed DAGs, DAG runs, task states and variables; every other Airflow part is stateless around it.
Airflow scheduler
The Airflow process that creates DAG runs when they are due and decides which task instances may run next, within the concurrency limits.
Airflow worker
The process that runs one task’s code and reports its state to Airflow’s API server.
Apache Airflow
An open-source orchestrator that runs pipelines written as Python DAGs: it schedules tasks, starts each when the tasks before it succeed, and retries or reruns them.
Asset (Airflow)
A name Airflow tracks for a piece of data, such as a table or a file. Tasks say when they updated it, and other DAGs can be scheduled to start when it changes. Airflow never reads the data itself.
Asset (Dagster)
In Dagster, a table, file or other piece of data that a pipeline produces, described in code together with the assets it is built from.
Asset event
Airflow’s record that an asset was updated: written when a task that lists the asset as an outlet succeeds, or when a watcher or an outside system reports a change.
Asset-aware scheduling
Starting an Airflow DAG when the data it reads has been updated, recorded as asset events, instead of only at a clock time.
AssetWatcher
An Airflow object attached to an asset that listens to an outside source, such as a message queue, and records an asset event each time a message arrives. It runs as a trigger in the triggerer.
Backfill (pipelines)
Running a pipeline for past dates, to fill dates that never ran or to redo dates whose output was wrong.
CeleryExecutor
An Airflow executor that sends tasks through a message broker to a pool of long-running workers.
completeness record
A table with one row per source and business day saying whether that day’s data is complete, written by each load in the same transaction as its data.
Control plane
The part of a system that decides what runs and when, and keeps its state, as opposed to the workers that do the work.
DAG bundle
The collection of DAG files and their supporting files that Airflow reads, such as a local folder or a Git repository; a Git bundle lets each run keep the code it started with.
DAG processor
The Airflow process that reads DAG files, runs their top-level code and saves the parsed DAGs to the metadata database.
DAG run
One run of a DAG. Airflow creates a new one for each scheduled time or manual trigger.
DAG version
The version of a DAG’s code, from a versioned DAG bundle such as Git, that a DAG run was created with. By default the run, and any later clear of it, uses that version, not the newest code.
dagrun_timeout
An Airflow DAG setting that limits how long one run may take. When it runs out, the run ends and tasks still running are marked skipped.
Data interval
The time range an Airflow DAG run is meant to cover, set by its timetable; with a cron trigger timetable its start and end are the same instant.
Deferrable operator
An Airflow operator that can hand its wait to a trigger running in the triggerer process, freeing its worker slot until the condition is met.
executor (Airflow)
The part of the Airflow scheduler that hands a queued task to somewhere that runs it: a local process, a Celery worker or a Kubernetes pod.
Flow (Prefect)
In Prefect, a Python function marked with @flow that calls tasks with ordinary code, so the order of work is decided as it runs.
Hook (Airflow)
The Airflow class that connects to one outside system using a stored connection; operators use hooks underneath, and task code can call them directly.
KubernetesExecutor
An Airflow executor that runs each task instance in its own Kubernetes pod, which starts, runs the task and stops.
leaf task
A task in a DAG with no downstream tasks; Airflow decides whether a DAG run succeeded or failed from the states of its leaf tasks.
Logical date
The date-time that names an Airflow DAG run, equal to the start of its data interval and stored in UTC.
Operator (Airflow)
A template for one kind of task in Airflow, such as running a shell command or a SQL query. Each task in a DAG is made from an operator with its own arguments.
Provider (Airflow)
A separately installed Airflow package that adds operators, sensors, hooks and connections for one outside system.
Reprocess behaviour
The Airflow backfill setting that decides which dates in the range get a new run: only dates with no run (none), also dates whose run failed (failed), or every date (completed).
Retry policy (Airflow)
A rule set on an Airflow task that decides, from the exception raised, whether a failed try is retried, retried after a set delay, or failed at once.
Sensor (Airflow)
An Airflow task that waits until a condition is true, such as a file existing, before the tasks after it run.
Task callback
A function Airflow calls when a task changes state, such as when a try fails and will be retried, or when the last try fails.
task instance
One task in one DAG run. It has a state, such as queued, running, success, failed or upstream_failed.
Task SDK (Airflow)
The library Airflow 3 task code runs on. It talks to the API server for the task, including storing and reading XComs.
TaskFlow API
Airflow’s way of writing tasks as decorated Python functions, where a return value is passed to the next task as an argument.
Template field (Airflow)
An operator argument that Airflow fills in with Jinja just before the task runs, so it can hold values like the run’s date.
Timetable (Airflow)
The object behind a DAG’s schedule that decides when runs are created and which logical date and data interval each run gets.
trigger rule
The condition a task’s upstream tasks must meet before Airflow runs it. The default, all_success, needs every upstream task to succeed.
triggerer (Airflow)
The Airflow process that waits on many deferred tasks at once in an event loop and resumes each when its condition fires.
upstream task
A task that another task depends on directly: it must finish before the other may run. The other task is its downstream task.
Work pool (Prefect)
In Prefect, a queue of scheduled flow runs that workers in your own infrastructure poll, so the code runs on your machines.
Worker slot
A place to run one Airflow task at a time. A task holds its slot while it runs, even if it is only waiting.
XCom
A small value one Airflow task stores for another task to read, kept under a key together with the DAG, run and task that made it.
XCom backend
The part of Airflow that decides where XCom values are stored. The default keeps them in the metadata database; a custom one can store them elsewhere.