liveBook · Manning

Asynchronous programming

As explained in Data Pipelines with Apache Airflow, Second Edition

Asynchronous processing is execution in which a task can progress or await conditions without continuously occupying a worker.

Asynchronous programming lets a task begin and then proceed without continuously waiting for it to finish. In Airflow, this is useful when tasks spend much of their time waiting for external systems, such as a Spark job. section 9.5.1

Airflow’s triggerer handles this waiting work. A deferrable task moves from a worker to the triggerer, which monitors its external condition asynchronously and leaves the worker available for other tasks. section 9.5.1 section 1.2.3

The execution model separates active work from waiting:

  • Workers perform tasks that are ready to run. section 1.2.3
  • The triggerer monitors deferred tasks and external completion conditions. section 9.5.1
  • The scheduler checks dependencies and can defer tasks that depend on external resources. section 1.2.3
  • Python’s asyncio functionality enables one component to manage many waiting tasks concurrently. section 9.5.1

Waiting for a Spark job

With only ten workers, ten long-running jobs could occupy the workers in batches. Deferring those jobs lets the triggerer monitor their Spark responses concurrently, allowing workers to handle tasks that are ready to run. section 9.5.1

Figure 9.6 In the standard (nondeferrable) method of running tasks, each task must be assigned to a worker. The deferrable approach transfers all the tasks to the triggerer.

Compare standard execution, where each task occupies a worker, with deferrable execution, where waiting tasks move to the triggerer. section 9.5.1

How Data Pipelines with Apache Airflow, Second Edition covers it

How deep it goes
Explains worker deferral, triggerer monitoring, and asyncio-based parallelism, but stops short of implementation code.
Examples
Uses long-running Spark jobs and a ten-worker capacity constraint to illustrate waiting-task concurrency.
What it assumes
Assumes familiarity with Airflow workers and external task conditions while identifying Python asyncio as an implementation requirement.
What you can do after
Apply it through Airflow’s deferrable-task pattern to move waiting work from workers to the triggerer.
How it connects
Connects asynchronous programming with Airflow, triggerers, deferrable tasks, workers, schedulers, and external systems.

Also explained in

Compare how 28 books explain asynchronous programming →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Data Pipelines with Apache Airflow, Second Edition. The section links point to the parts of the book it draws on.