You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
docs: Add usage guide on how to submit some tasks locally instead of k8s (#723)
* docs: Add usage guide on how to submit some tasks locally instead of k8s
* Apply suggestions from code review
Co-authored-by: Nick <[email protected]>
---------
Co-authored-by: Nick <[email protected]>
Copy file name to clipboardExpand all lines: docs/modules/airflow/pages/usage-guide/using-kubernetes-executors.adoc
+46Lines changed: 46 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -31,6 +31,52 @@ spec:
31
31
# ...
32
32
----
33
33
34
+
== Task startup latency
35
+
36
+
While there are many benefits to spawning a dedicated Pod for every task, this introduces some latency.
37
+
The shorter the actual task runs, the higher the effect of this latency get's on the overall DAG runtime.
38
+
39
+
If your tasks don't do computationally expensive things (e.g. only submit a query to a Trino cluster), you can schedule them to run locally (on the scheduler) and not spawn a Pod to reduce the DAG runtime.
40
+
41
+
To achieve this enable the `LocalExecutor` in your Airflow stacklet with
42
+
43
+
[source,yaml]
44
+
----
45
+
spec:
46
+
webservers:
47
+
envOverrides: &envOverrides
48
+
# We default our tasks to KubernetesExecutor, however, tasks can opt in to using the LocalExecutor
49
+
# See https://docs.stackable.tech/home/stable/airflow/usage-guide/using-kubernetes-executors/
Afterwards tasks can opt-in to the `LocalExecutor` using
58
+
59
+
[source,python]
60
+
----
61
+
@task(executor="LocalExecutor")
62
+
def hello_world():
63
+
print("hello world!")
64
+
----
65
+
66
+
As an alternative if *all* tasks of your DAG should run locally, you can also configure this on a DAG level (tasks can still explicitly use `KubernetesExecutor`):
67
+
68
+
[source,python]
69
+
----
70
+
with DAG(
71
+
dag_id="hello_worlds",
72
+
default_args={"executor": "LocalExecutor"}, # Applies to all tasks in the Dag
73
+
) as dag:
74
+
----
75
+
76
+
See the https://airflow.apache.org/docs/apache-airflow/stable/core-concepts/executor/index.html#using-multiple-executors-concurrently[official Airflow documentation] for details.
77
+
78
+
TIP: You might need to increase the scheduler resources, as it now runs more stuff.
79
+
34
80
== Logging
35
81
36
82
Kubernetes Executors and their respective Pods only live as long as the task they are executing.
0 commit comments