Airflow Pools and Priority

Pools limit how many tasks use one resource at the same time. Priority decides which waiting task goes first when slots are scarce. Together they protect fragile systems and make sure that urgent work runs early.

The Parking Lot Picture

A small parking lot holds five cars. A sixth car must wait at the gate until a space opens. A guard lets VIP cars in first. A pool is the parking lot, a slot is one space, and priority is the guard's list.

 Pool "warehouse"  (5 slots)
 ┌────┬────┬────┬────┬────┐
 │ T1 │ T2 │ T3 │ T4 │ T5 │   ← running
 └────┴────┴────┴────┴────┘
   Waiting at the gate:  T6   T7   T8

Why Pools Matter

A database may accept only ten connections. Thirty tasks that all query it would crash it or get refused. A pool of ten slots keeps the database safe, and the extra tasks wait their turn.

Create a Pool

In the UI

Open Admin, then Pools. Click the plus button, enter a name, set the number of slots, and save.

With the CLI

airflow pools set warehouse 5 "Limit for warehouse connections"
airflow pools list

Assign Tasks to a Pool

from airflow.operators.python import PythonOperator

load_orders = PythonOperator(
    task_id="load_orders",
    python_callable=load_orders,
    pool="warehouse",
    pool_slots=1,
)

load_big_table = PythonOperator(
    task_id="load_big_table",
    python_callable=load_big_table,
    pool="warehouse",
    pool_slots=3,
)

The task load_big_table takes three slots, so it counts as a heavy user. Two slots remain for small tasks.

The Default Pool

Tasks without a pool setting use default_pool. It holds 128 slots by default. Change its size in the UI to cap total task use.

Priority Weight

When more tasks wait than slots exist, the scheduler picks tasks with the highest priority_weight first.

urgent_report = PythonOperator(
    task_id="urgent_report",
    python_callable=build_report,
    pool="warehouse",
    priority_weight=10,
)

cleanup_logs = PythonOperator(
    task_id="cleanup_logs",
    python_callable=clean_logs,
    pool="warehouse",
    priority_weight=1,
)
 Waiting queue (before)      Waiting queue (after sorting by priority)
 cleanup_logs  (1)           urgent_report (10)
 urgent_report (10)    ──►   cleanup_logs  (1)

Weight Rules

The weight_rule setting controls how Airflow adds up priority across a chain of tasks.

RuleMeaning
downstreamWeight grows with the number of tasks after this one (default)
upstreamWeight grows with the number of tasks before this one
absoluteAirflow uses only the number you set

Pool Use Cases

  • Limit API calls to a service with a rate limit.
  • Protect a small database from too many connections.
  • Reserve capacity for important DAGs by giving them their own pool.
  • Throttle expensive machine learning jobs on shared hardware.

Pools versus Other Limits

LimitWorks Across
PoolAny tasks in any DAG that name the pool
max_active_tasksOne DAG
parallelismWhole installation

Common Mistakes

  • Creating a pool with too few slots, which starves tasks in the queue.
  • Naming a pool in code that does not exist yet. The task stays scheduled forever.
  • Setting every priority to a high number, which removes any ordering effect.

A Worked Example

A team runs three DAGs that all write to one reporting database. The database allows six connections. The team creates a pool named reporting_db with six slots. Each writing task joins that pool. Heavy month-end jobs use two slots each and carry a high priority weight. At peak time, Airflow runs six slots worth of work and queues the rest in priority order, so the database never refuses a connection.

Key Takeaways

  • A pool caps parallel use of one resource.
  • Slots count how much each task consumes.
  • Priority weight orders the waiting queue.