CLOUD CONCEPT

Directed Acyclic Graphs

Directed acyclic graphs model tasks and their dependencies using one-way connections that never form a cycle.

Cloud Concepts Hub →

What is Directed Acyclic Graphs

A directed acyclic graph, or DAG, defines which tasks depend on others without allowing a dependency path to return to its starting task. In cloud data pipelines, DAGs help orchestrators run work in the correct order, execute independent tasks concurrently, and identify where failures block downstream processing.

A directed acyclic graph consists of vertices and directed edges. In pipeline orchestration, vertices usually represent tasks, while edges represent dependencies between them. If a transformation depends on an extraction task, the extraction must satisfy the dependency before the transformation becomes eligible to run. Acyclic means that following directed edges can never lead back to the starting vertex. This prevents circular requirements such as task A waiting for task B while task B waits for task A.

A DAG defines a partial order, not necessarily a single execution sequence. Consider a daily sales pipeline that extracts orders and customer records independently, validates each dataset, joins the validated results, and publishes aggregates. The two extraction branches can run concurrently, but the join must wait for both validation branches. A topological ordering places every upstream task before its downstream dependents; several valid orderings may exist for the same graph.

Cloud orchestrators interpret these dependencies alongside schedules, resource limits, task states, and execution policies. A task with no unfinished dependencies is not guaranteed to start immediately: concurrency limits, worker capacity, or service quotas may delay it. Likewise, an edge does not inherently specify that the upstream task must succeed. The orchestrator's trigger rules determine whether downstream work requires success, completion, or another combination of upstream states.

Amazon Managed Workflows for Apache Airflow runs Apache Airflow, where engineers define DAGs in Python and use operators to submit work to external systems. For example, an Airflow DAG can start AWS Glue jobs, wait for completion, and then launch a publishing task. Keep DAG-definition code lightweight because Airflow parses it repeatedly; expensive queries and data transformations belong in tasks rather than in top-level definition code.

AWS Step Functions can express similar dependency structures through sequential tasks, parallel branches, and Map states. However, a Step Functions state machine is not necessarily a DAG: transitions can form loops. Choose Airflow when its scheduling, data-interval handling, backfills, and ecosystem fit the workload. Choose Step Functions when managed state-machine execution and AWS service integrations fit the workflow. Both can orchestrate data processing, but their workflow models are not interchangeable.

Acyclic structure does not prohibit retries or recurring pipeline runs. Retrying a task repeats execution without adding a backward dependency edge, and each scheduled run is a separate execution of the workflow definition. For reliable recovery, make tasks idempotent, identify input partitions explicitly, and publish outputs safely. Retrying a database load without deduplication or transactional protection can create duplicate records even when the DAG itself is correct.

DAGs make dependencies visible and expose opportunities for parallelism, but they do not automatically guarantee data quality, exactly-once processing, or low latency. The longest dependency path and available compute constrain completion time. Large graphs also introduce scheduling overhead and operational complexity. Pass references to large datasets rather than transferring those datasets through orchestration metadata, and monitor task duration, retries, failures, and downstream freshness to understand the pipeline's actual health.

Key aspects of Directed Acyclic Graphs

DAGs provide an acyclic dependency structure for ordered and parallel execution, while operational policies and task design determine reliability.

Directed dependencies

Edges specify prerequisite relationships between tasks. Define dependencies from actual data or control requirements rather than adding arbitrary ordering that unnecessarily serializes work.

No circular dependency paths

A DAG cannot contain a directed path that returns to its starting vertex. Model recurring schedules as separate runs and task retries as execution policies, not backward dependency edges.

Partial ordering and parallelism

Independent branches can execute concurrently, while join points wait for their configured prerequisites. Actual parallelism still depends on worker capacity, concurrency settings, and downstream service quotas.

Explicit execution policies

Dependency structure and task-state rules work together to determine readiness. Configure retries, timeouts, failure handling, and downstream trigger conditions explicitly rather than assuming the graph provides them.

Recoverable, repeatable tasks

Idempotent writes and explicit input partitions make retries and historical reprocessing safer. A valid DAG alone does not prevent duplicate side effects or inconsistent outputs.

Separation of orchestration and processing

Use the orchestrator to coordinate work and track state while processing systems handle large datasets. Exchange object locations, partition identifiers, and job IDs instead of large payloads.

Cloud services for Directed Acyclic Graphs

Amazon MWAA or AWS Step Functions can coordinate a pipeline whose processing stages run in AWS Glue and AWS Batch. For example, the orchestrator can start independent Glue transformations, wait for their successful completion, submit a Batch aggregation job, and then publish the output. AWS Glue workflows provide another coordination option when the pipeline primarily involves Glue jobs and crawlers. Assign dependency and retry ownership clearly rather than duplicating control across multiple orchestration layers. Store datasets in durable storage and pass references between tasks; keep orchestration state focused on execution status and small control values.

AWS Step Functions image AWS Step Functions

Coordinates service calls using state machines with sequential tasks, parallel branches, and Map states. It can implement DAG-shaped workflows, but it also supports cyclic transitions, so not every state machine is a DAG.

Open AWS Step Functions →
AWS Glue image AWS Glue

AWS Glue workflows coordinate related jobs, crawlers, and triggers through dependency-based processing flows. Glue jobs can also serve as processing tasks within an Airflow DAG or a Step Functions workflow.

Open AWS Glue →
AWS Batch image AWS Batch

Supports job dependencies so eligible jobs can wait for prerequisite jobs to complete successfully. An orchestrator can submit Batch jobs as compute-intensive stages within a larger DAG.

Open AWS Batch →