Skip to main content
πŸ“˜ Complete PDF

Airflow Certification Practice Test 09

Practice Test 09

Question 1 of 20
πŸ“‹ Multiple Choice
Question 161
A retail company runs 500 DAGs daily. Developers request 50 additional permanent worker VMs because workflows occasionally queue during peak morning hours. An infrastructure audit reveals that worker CPU utilization exceeds 90% for only 20 minutes each day, remaining under 15% for the rest of the day. What is the BEST architectural recommendation?
βœ“
A. Implementing an Autoscaling Worker Strategy (e.g., KEDA with Celery or KubernetesExecutor)
B. Creating 500 additional Airflow Variables
C. Rewriting all DAGs from scratch in bash scripts
D. Provisioning 50 permanent high-memory worker VMs running 24/7
Answer
βœ… A. Implementing an Autoscaling Worker Strategy (e.g., KEDA with Celery or KubernetesExecutor)
Explanation

1. Direct Question Answer & Core Concept βœ… A. Implementing an Autoscaling Worker Strategy (e.g., KEDA with Celery or KubernetesExecutor)

Core Concept: Horizontal Pod Autoscaling (via KEDA or KubernetesExecutor) scales worker capacity dynamically in response to queued tasks during peak windows, scaling back to zero or baseline when queues clear to prevent cost waste.

2. Deep-Dive Analytical Explanation Adding 50 permanent worker VMs to handle a brief 20-minute daily spike is an expensive FinOps anti-pattern. An autoscaling strategy using KEDA (Kubernetes Event-driven Autoscaling) monitors the Celery Redis queue or Airflow metadata database queue count. When tasks surge at 8:00 AM, KEDA scales worker pods up in seconds; as tasks finish, KEDA terminates idle workers, saving over 80% on compute infrastructure costs.

3. Comprehensive Option Analysis & Distractor Dissection - **A. Creating 500 additional Airflow Variables:** Adds metadata records; has zero connection to worker compute capacity. - **B. Rewriting all DAGs in bash scripts:** Immense engineering effort that provides no autoscaling or queue management benefits. - **C. Provisioning 50 permanent workers running 24/7:** Burns massive cloud budget for idle infrastructure that sits unused for 23.5 hours every day.

4. Architectural & Execution Context / Physical Execution KEDA polls Airflow queue metrics via SQL (`SELECT count(*) FROM task_instance WHERE state='queued'`). When queued tasks exceed a threshold, the Kubernetes Horizontal Pod Autoscaler (HPA) adds worker pods dynamically.

5. Practical Code Example

# KEDA ScaledObject configuration for dynamic Airflow worker autoscaling
apiVersion: keda.sh/v1alpha1
kind: ScaledObject
metadata:
  name: airflow-worker-autoscaler
  namespace: airflow-prod
spec:
  scaleTargetRef:
    name: airflow-worker-deployment
  minReplicaCount: 2   # Baseline capacity for routine daytime tasks
  maxReplicaCount: 40  # Bursts automatically during peak morning surges
  triggers:
    - type: postgresql
      metadata:
        query: "SELECT CEIL(COUNT(*)::decimal / 16) FROM task_instance WHERE state='queued';"
        targetQueryValue: "1"

6. Key Takeaway Handle bursty orchestration workloads by deploying autoscaling workers via KEDA or KubernetesExecutor rather than paying for permanent idle VMs.

7. Best Practice & Production Recommendation Set a conservative `scaleDownDelaySeconds` (e.g., 300 seconds) in your autoscaler to prevent thrashing when tasks arrive in quick successive batches.

8. Real-World Engineering Scenario An e-commerce company spent $15,000 monthly running 30 permanent workers for morning batch jobs. Switching to KubernetesExecutor dynamic autoscaling dropped monthly worker spend to $2,200 while eliminating all morning queue bottlenecks.

9. Common Exam Trap / Anti-Pattern / Misconception Using static worker pools for bursty batch workloads. Static sizing forces teams to choose between expensive over-provisioning or painful queue bottlenecks.

10. Related InsightfulSaga Tutorial Master these concepts in [Airflow Production Operations](/tutorials/airflow/scaling-workers-horizontal-autoscaling).

Answered: 0 / 20
Question Navigator (Test 09)0% Answered