Airflow Architecture
Airflow architecture describes the parts that read your pipelines, schedule them, run them, and show the results on screen. Each part has one clear job. Knowing these parts helps you fix problems faster and plan a setup that grows with your data.
The Restaurant Picture
Think of Airflow as a busy restaurant. Customers place orders, a manager decides what to cook and when, and chefs prepare the dishes. A board on the wall shows the status of every order.
Restaurant Airflow ───────────────────────────────────────────────────── Recipe book → DAG files Manager reading the order → Scheduler board Order ledger → Metadata database Kitchen dispatcher → Executor Chefs → Workers Display window for guests → Web server (UI) Staff who wait for a → Triggerer delivery truck
The Main Components
DAG Files
DAG files are Python files stored in the dags folder. They describe what work to do and in what order. Airflow reads them often, so a saved change shows up within a short time.
Scheduler
The scheduler is the brain. It reads DAG files, checks the schedule, creates DAG runs, and decides which tasks are ready. A task becomes ready when all tasks before it have finished. The scheduler then hands that task to the executor.
Metadata Database
The metadata database stores every fact Airflow needs to remember: DAG runs, task states, connections, variables, XComs, and user accounts. Every component reads from it and writes to it. SQLite works for a quick test. PostgreSQL or MySQL suit real projects.
Executor
The executor decides where and how tasks run. It lives inside the scheduler process and acts like a dispatcher. LocalExecutor runs tasks on the same machine. CeleryExecutor and KubernetesExecutor send tasks to other machines.
Workers
Workers do the real work. A worker picks up a task, runs your code, and reports success or failure back to the database.
Web Server
The web server powers the user interface. You use it to watch runs, read logs, trigger DAGs, and manage settings. The web server only shows data. Pipelines keep running even when it stops.
Triggerer
The triggerer handles deferrable tasks. These tasks wait for an outside event, such as a file arriving. The triggerer watches many waiting tasks with very little memory, so workers stay free for other jobs.
The Big Picture
┌──────────────┐ reads ┌────────────────┐
│ DAG files │ ─────────────► │ Scheduler │
└──────────────┘ └───────┬────────┘
│ sends ready tasks
▼
┌──────────────┐ ┌────────────────┐
│ Web server │ │ Executor │
│ (UI) │ └───────┬────────┘
└──────┬───────┘ │
│ ▼
│ ┌────────────────┐
│ │ Worker 1 .. N │
│ └───────┬────────┘
│ read / write │ report state
▼ ▼
┌─────────────────────────────────────────────────┐
│ Metadata database │
└─────────────────────────────────────────────────┘
How One DAG Run Moves Through the Parts
- The scheduler reads the DAG file and notices the schedule is due.
- The scheduler writes a new DAG run to the metadata database.
- The scheduler finds tasks with no waiting parents and marks them as queued.
- The executor sends each queued task to a worker.
- The worker runs the task code and writes the result to the database.
- The scheduler sees the finished task and releases the next ones.
- The web server reads the database and shows live colors in the UI.
Component Summary
| Component | Main Job | Needed? |
|---|---|---|
| Scheduler | Plans and queues tasks | Always |
| Metadata database | Stores all state | Always |
| Executor | Chooses where tasks run | Always |
| Workers | Run task code | Always |
| Web server | Shows the UI | Almost always |
| Triggerer | Handles deferrable tasks | Only when used |
Single Machine and Distributed Setups
Single Machine
Every component runs on one computer. This layout fits learning, testing, and small pipelines. Setup takes minutes, and one server handles everything.
Distributed
Each component runs on its own machine or container. Many workers share the load, and a failed worker does not stop the others. Large teams choose this layout for heavy daily workloads.
Architecture in Newer Versions
Recent Airflow releases separate more duties into dedicated services. The DAG processor, which parses your files, runs as its own component in newer setups, and Airflow 3 replaces the classic web server with an API server. The core idea stays the same: a scheduler plans, workers execute, and a database remembers.
Key Takeaways
- The scheduler decides, the executor dispatches, and workers act.
- The metadata database acts as the single source of truth.
- The web server displays information and never runs your tasks.
- A distributed setup trades simplicity for scale and safety.
