📖 Scenario: You are working in a team that uses Apache Airflow to automate workflows. To better understand how Airflow works, you want to explore its main components: the scheduler, webserver, executor, and metadata database.
🎯 Goal: Build a simple Python script that defines the main Airflow components as variables, configures a basic executor type, and prints out the Airflow architecture setup summary.
📋 What You'll Learn
Create variables for Airflow components with exact names and values
Add a configuration variable for the executor type
Use a dictionary to represent the Airflow architecture setup
Print the final Airflow architecture dictionary
💡 Why This Matters
🌍 Real World
Understanding Airflow's architecture helps teams configure and troubleshoot workflow automation systems effectively.
💼 Career
Knowledge of Airflow components is essential for roles like DevOps engineers, data engineers, and workflow automation specialists.
Progress0 / 4 steps
1
Define Airflow core components
Create four string variables with these exact names and values: scheduler set to "Airflow Scheduler", webserver set to "Airflow Webserver", executor set to "SequentialExecutor", and metadata_db set to "PostgreSQL Metadata Database".
Apache Airflow
Hint
Use simple assignment statements to create variables with the exact names and values.
2
Add executor configuration
Create a string variable called executor_type and set it to "LocalExecutor" to represent a different executor configuration.
Apache Airflow
Hint
Just add one more variable assignment for executor_type.
3
Create Airflow architecture dictionary
Create a dictionary called airflow_architecture with keys "Scheduler", "Webserver", "Executor", and "Metadata DB". Assign the variables scheduler, webserver, executor_type, and metadata_db as their respective values.
Apache Airflow
Hint
Use a dictionary literal with the exact keys and assign the existing variables as values.
4
Print Airflow architecture summary
Write a print statement to display the airflow_architecture dictionary.
Apache Airflow
Hint
Use print(airflow_architecture) to show the dictionary content.
Practice
(1/5)
1. Which Airflow component is responsible for deciding when and which tasks to run?
easy
A. Scheduler
B. Webserver
C. Executor
D. Metadata Database
Solution
Step 1: Understand the role of the scheduler
The scheduler checks the workflow definitions and decides the timing and order of task execution.
Step 2: Differentiate from other components
The executor runs tasks, the webserver shows status, and the metadata DB stores info. Only the scheduler plans tasks.
Final Answer:
Scheduler -> Option A
Quick Check:
Task planning = Scheduler [OK]
Hint: Scheduler plans tasks; executor runs them [OK]
Common Mistakes:
Confusing executor with scheduler
Thinking webserver runs tasks
Assuming metadata DB schedules tasks
2. Which of the following is the correct way to start the Airflow webserver using the CLI?
easy
A. airflow webserver -p
B. airflow webserver start
C. airflow start webserver
D. airflow webserver
Solution
Step 1: Recall the Airflow CLI command for webserver
The correct command to start the webserver is simply airflow webserver.
Step 2: Analyze other options
airflow webserver start adds an unnecessary 'start', airflow start webserver reverses the order, and airflow webserver -p adds a port flag which is valid but incomplete without specifying the port number explicitly.
Final Answer:
airflow webserver -> Option D
Quick Check:
Start webserver = airflow webserver [OK]
Hint: Use 'airflow webserver' to start the UI [OK]
Common Mistakes:
Adding extra words like 'start'
Reversing command order
Incorrect or incomplete flags
3. Given the following Airflow setup: The scheduler triggers a task, the executor runs it, and the metadata DB records the status. What will happen if the metadata DB is down?
medium
A. Tasks will run but status won't be saved
B. Scheduler will stop scheduling tasks
C. Webserver will crash immediately
D. Executor will ignore tasks
Solution
Step 1: Understand metadata DB role
The metadata DB stores task states and workflow info. If it is down, Airflow components cannot read or write task status.
Step 2: Impact on scheduler and executor
The scheduler depends on the metadata DB to know which tasks to schedule. Without DB access, it cannot schedule new tasks. The executor waits for tasks from the scheduler.
Final Answer:
Scheduler will stop scheduling tasks -> Option B
Quick Check:
Metadata DB down stops scheduler [OK]
Hint: Metadata DB failure stops scheduler [OK]
Common Mistakes:
Thinking tasks run without DB
Assuming webserver crashes immediately
Believing executor ignores tasks
4. You notice that tasks are not running even though the webserver shows them as scheduled. Which component should you check first to debug this issue?
medium
A. Executor
B. Scheduler
C. Metadata Database
D. Webserver
Solution
Step 1: Analyze symptoms
Tasks are marked scheduled in the webserver UI but are not running. This means scheduling is done but execution is not happening.
Step 2: Identify responsible component
The executor runs the tasks. If tasks are scheduled but not running, the executor might be stuck or misconfigured.
Final Answer:
Executor -> Option A
Quick Check:
Tasks not running? Check executor [OK]
Hint: Scheduled but not running? Check executor first [OK]
Common Mistakes:
Checking scheduler when scheduling works
Restarting webserver unnecessarily
Ignoring executor logs
5. In a distributed Airflow setup, which component must be shared and accessible by both the scheduler and executor to coordinate task execution properly?
hard
A. Webserver
B. Local task logs
C. Metadata Database
D. Scheduler's local cache
Solution
Step 1: Understand distributed setup needs
In distributed Airflow, multiple executors and schedulers may run on different machines.
Step 2: Identify shared resource for coordination
The metadata database stores task states and is the central point both scheduler and executor use to coordinate which tasks to run and their status.
Step 3: Exclude other options
The webserver is for UI only, local logs are not shared, and scheduler's local cache is not accessible by executors.
Final Answer:
Metadata Database -> Option C
Quick Check:
Shared coordination = Metadata DB [OK]
Hint: Metadata DB is central shared store in distributed Airflow [OK]
Common Mistakes:
Thinking webserver shares task state
Assuming local logs are shared
Believing scheduler cache syncs executors
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.