Mental model
Airflow schedules task instances against explicit data intervals in a directed acyclic task graph; Dagster defines persistent assets and derives dependencies from upstream asset inputs. Airflow makes execution order and replay windows visible, while Dagster centers lineage and materialization state. In both systems, retries are safe only when each partition's external writes are idempotent and observable.
Learning outcomes
- Explain how an Airflow DAG run creates task instances for a data interval.
- Describe how Dagster asset keys, function inputs, and partition definitions express lineage.
- Estimate backfill compute work from partition size and per-row processing cost.
- Make retries and publication safe with deterministic partition keys and a final manifest.
Theory
An Airflow DAG describes when a workflow runs, which tasks it contains, and the dependency edges that order those tasks. The scheduler creates a DAG run for a data interval, then task instances for that run. The interval identifies the period of source data a task should process; the logical date is not necessarily the wall-clock time when a worker starts. Catchup and backfill let an operator create runs for earlier intervals, while retries repeat a task instance whose previous attempt failed. Keep large tables and dataframes in storage and pass small references such as partition keys or manifest URIs through XCom.
Dagster's software-defined asset describes an object that should exist in persistent storage and the function that computes or updates it. The asset key names the object; upstream assets are inferred from function parameters or declared as dependencies. An IO manager stores an output and loads it for downstream computations. A partition definition divides an asset into addressable keys, such as one key per event date. Materialization events record that an asset computation produced an output, but the actual durability and atomicity still depend on its storage and IO manager.
These models answer different operational questions. An Airflow task graph is a natural fit when the core unit is an ordered operation, including external jobs, notifications, and conditional branches. Dagster asset definitions make data lineage and selective rematerialization central, which helps when many consumers share tables or files. Both can execute partitions and retry work; neither automatically makes a side effect exactly once. A task or asset should write to a deterministic partition location, verify its inputs, and publish a small commit marker only after the output is complete.
A replay boundary needs the same care as a first run. If a task uses the current clock instead of the run's interval, a backfill may read today's data for yesterday's partition. If a retry appends blindly to a table, it may duplicate rows even though the orchestrator correctly reruns only a failed task. Use the interval or partition key as part of the input query and write identity, make replacement/upsert semantics explicit, and preserve the source snapshot or manifest used for each materialization.
Worked backfill estimate
For a partitioned transform, approximate total CPU work as:
Here, C_cpu is CPU-seconds, P is the number of partitions, R_p is rows per partition, and t_r is average CPU-seconds per row. A six-hour gap with 2,000,000 rows per hourly partition and 8 microseconds of CPU per row represents 6 × 2,000,000 × 0.000008 = 96 CPU-seconds. With eight effective worker cores, the ideal compute-only floor is 96 / 8 = 12 seconds. API latency, storage reads, task startup, skew, and scheduler limits make actual wall time longer. Airflow would create six data-interval runs; Dagster would materialize the six corresponding partition keys.
Failure modes and misconceptions
- Confusing logical time with worker start time. The data interval says which slice to process. A late task should still read that interval rather than querying whatever is newest when it begins.
- Turning catchup on without bounding replay. A long pause can create a large backlog that competes with live work. Estimate partitions, worker capacity, and downstream rate before a broad backfill.
- Making retries append-only. A network timeout after a successful write can make a retry duplicate records. Use deterministic partition paths, idempotent replacement or keyed upserts, and a commit marker.
- Treating an asset materialization as a storage guarantee. The event records a computation result; verify the IO manager's persistence and the atomicity of the underlying object or table.
- Declaring the wrong dependency. Dagster infers inputs from function parameters and asset keys. If the code's input name does not identify the intended upstream asset, declare the key explicitly and inspect the resulting lineage.
- Passing data through orchestration metadata. XCom and run events are suited to small references and metadata, not multi-gigabyte frames or full datasets.
Trade-offs
| Concern | Airflow task DAG | Dagster asset graph |
|---|---|---|
| Main modeling unit | Scheduled tasks and their execution dependencies | Persistent data assets and their upstream dependencies |
| Replay identity | DAG run data interval and task instance | Asset key and selected partition |
| Useful visibility | Run state, task retries, scheduling and branching | Asset lineage, materializations, partitions and freshness |
| Common operational risk | Catchup or retry creates load and repeats side effects | Materialization metadata can be mistaken for durable output |
Choose based on the unit operators need to inspect and recover. A task-first workflow with many external operations may stay clearer as an Airflow DAG. A shared data product with consumers that need lineage and per-partition materialization may be easier to operate as Dagster assets. In either system, keep task code deterministic, version the transformation and contract, and measure queue time separately from execution time.
Decision scenario
A commerce pipeline missed six hourly partitions after an API outage. Each interval contains about two million order events, and the downstream warehouse is already close to its ingestion limit. Backfill only the missing interval keys, cap active runs below the warehouse's measured capacity, and have each run replace or upsert its own partition before publishing its manifest. If the source can revise old events, pin the same source snapshot for retries and record that snapshot ID with the materialization. Do not rerun the entire month merely because one partition failed.
Implementation pattern
This Airflow 3 task graph asks an export service for a stable interval snapshot, then verifies the finalized object's byte length and SHA-256 metadata before publishing the downstream manifest. The API returns only metadata; the data stays in object storage. Repeating a run addresses the same immutable interval key and snapshot.
pythonimport jsonimport osfrom datetime import timedeltaimport boto3import pendulumimport requestsfrom airflow.sdk import dag, get_current_context, task@dag(dag_id="hourly_order_snapshot", schedule="@hourly",start_date=pendulum.datetime(2026, 1, 1, tz="UTC"), catchup=False,max_active_runs=4)def hourly_order_snapshot():@task(retries=2, retry_delay=timedelta(minutes=2))def stage_interval() -> dict[str, str | int]:context = get_current_context()start = context["data_interval_start"].in_timezone("UTC")end = context["data_interval_end"].in_timezone("UTC")partition = start.strftime("%Y-%m-%dT%H")response = requests.get(os.environ["ORDERS_EXPORT_API"],params={"start": start.isoformat(), "end": end.isoformat()},timeout=(3, 60),)response.raise_for_status()descriptor = response.json()if descriptor["partition"] != partition or descriptor["row_count"] < 0:raise ValueError("export descriptor does not match the interval")s3 = boto3.client("s3")bucket = os.environ["ORDERS_BUCKET"]head = s3.head_object(Bucket=bucket, Key=descriptor["object_key"])expected = (descriptor["content_length"], descriptor["sha256"])if (head["ContentLength"], head["Metadata"].get("sha256")) != expected:raise ValueError("staged object does not match the export descriptor")return {"bucket": bucket, **descriptor}@taskdef publish_manifest(staged: dict[str, str | int]) -> None:s3 = boto3.client("s3")key = f"orders/hour={staged['partition']}/manifest.json"manifest = {"object_key": staged["object_key"],"snapshot_id": staged["snapshot_id"],"row_count": staged["row_count"],}s3.put_object(Bucket=staged["bucket"],Key=key,Body=json.dumps(manifest).encode("utf-8"),ContentType="application/json",)publish_manifest(stage_interval())hourly_order_snapshot()