Skip to content

Commit 5130fd6

Browse files
wolfierCloud Composer Team
authored and
Cloud Composer Team
committed
Compare taskgroup and subdag (#20700)
GitOrigin-RevId: 6b0c52898555641059e149c5ff0d9b46b2d45379
1 parent 97f0c27 commit 5130fd6

File tree

1 file changed

+41
-2
lines changed

1 file changed

+41
-2
lines changed

docs/apache-airflow/concepts/dags.rst

+41-2
Original file line numberDiff line numberDiff line change
@@ -605,8 +605,47 @@ Some other tips when using SubDAGs:
605605

606606
See ``airflow/example_dags`` for a demonstration.
607607

608-
Note that :doc:`pools` are *not honored* by :class:`~airflow.operators.subdag.SubDagOperator`, and so
609-
resources could be consumed by SubdagOperators beyond any limits you may have set.
608+
609+
.. note::
610+
611+
Parallelism is *not honored* by :class:`~airflow.operators.subdag.SubDagOperator`, and so resources could be consumed by SubdagOperators beyond any limits you may have set.
612+
613+
614+
615+
TaskGroups vs SubDAGs
616+
----------------------
617+
618+
SubDAGs, while serving a similar purpose as TaskGroups, introduces both performance and functional issues due to its implementation.
619+
620+
* The SubDagOperator starts a BackfillJob, which ignores existing parallelism configurations potentially oversubscribing the worker environment.
621+
* SubDAGs have their own DAG attributes. When the SubDAG DAG attributes are inconsistent with its parent DAG, unexpected behavior can occur.
622+
* Unable to see the "full" DAG in one view as SubDAGs exists as a full fledged DAG.
623+
* SubDAGs introduces all sorts of edge cases and caveats. This can disrupt user experience and expectation.
624+
625+
TaskGroups, on the other hand, is a better option given that it is purely a UI grouping concept. All tasks within the TaskGroup still behave as any other tasks outside of the TaskGroup.
626+
627+
You can see the core differences between these two constructs.
628+
629+
+--------------------------------------------------------+--------------------------------------------------------+
630+
| TaskGroup | SubDAG |
631+
+========================================================+========================================================+
632+
| Repeating patterns as part of the same DAG | Repeating patterns as a separate DAG |
633+
+--------------------------------------------------------+--------------------------------------------------------+
634+
| One set of views and statistics for the DAG | Separate set of views and statistics between parent |
635+
| | and child DAGs |
636+
+--------------------------------------------------------+--------------------------------------------------------+
637+
| One set of DAG configuration | Several sets of DAG configurations |
638+
+--------------------------------------------------------+--------------------------------------------------------+
639+
| Honors parallelism configurations through existing | Does not honor parallelism configurations due to |
640+
| SchedulerJob | newly spawned BackfillJob |
641+
+--------------------------------------------------------+--------------------------------------------------------+
642+
| Simple construct declaration with context manager | Complex DAG factory with naming restrictions |
643+
+--------------------------------------------------------+--------------------------------------------------------+
644+
645+
.. note::
646+
647+
SubDAG is deprecated hence TaskGroup is always the preferred choice.
648+
610649

611650

612651
Packaging DAGs

0 commit comments

Comments
 (0)