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
{{ message }}
Repository navigation
Multi Team: /dags screen is very slow to load with multiple teams #69041
We have onboarded approximately 10 teams onto a multi-team airflow instance, and have dags on the order of hundreds, and now the /dags screen takes approximately 10 seconds to load. Our test Airflow has only one team and the /dags screen loads almost instantly.
What you think should happen instead?
Since the Keycloak Auth Manager already uses caching, perhaps we need the api server to send out multiple calls simultaneously to evaluate dag permissions?
Operating System
Debian GNU/Linux 12 (bookworm)
Deployment
Other Docker-based deployment
Apache Airflow Provider(s)
keycloak
Versions of Apache Airflow Providers
apache-airflow-providers-keycloak==0.7.1
Official Helm Chart version
Not Applicable
Kubernetes Version
1.33.5
Helm Chart configuration
No response
Docker Image customizations
Some additional pip and apt packages
Anything else?
Multi team deployment using the Keycloak Auth Manager
I took a quick look at the Keycloak auth manager path and I could reproduce the lower-level behavior behind this.
KeycloakAuthManager.filter_authorized_dag_ids() wraps the result with cache/single-flight, but on cache miss it falls back to the base auth manager implementation. That base implementation checks each Dag id individually, so Keycloak ends up sending one authorization HTTP request per Dag id in that filter call.
I verified this locally with a small unit test: 25 Dag ids + mocked http_session.post resulted in 25 POST calls, each with a different resource_id claim.
I have not reproduced the full 10s /dags page load, but this per-Dag request pattern seems consistent with the reported slowdown when Keycloak calls have non-trivial latency.
AWS auth manager seems to avoid this by batching authorization checks in filter_authorized_dag_ids(). Would a similar batch path make sense for Keycloak?
BTW, this may also need area:providers / provider:keycloak labels.
Hey @Andrushika thanks for taking a look. Yes I think in the keycloak case it should only be necessary to check access for each resource type, rather than each dag. Perhaps the caching layer should be moved from filter_authorized_dag_ids() to _is_authorized()?
I don't think it is a good idea to only check permissions at the resource level... It would bypass the permission checking per resource_id. The related permission check is added in #61137 as intended, so DAG-level authorization still seems necessary.
I took a look at the source implementation. Parallelizing the N requests seems viable for reducing wall-clock latency.
Activity
Andrushika commentedon Jun 26, 2026
I took a quick look at the Keycloak auth manager path and I could reproduce the lower-level behavior behind this.
KeycloakAuthManager.filter_authorized_dag_ids()wraps the result with cache/single-flight, but on cache miss it falls back to the base auth manager implementation. That base implementation checks each Dag id individually, so Keycloak ends up sending one authorization HTTP request per Dag id in that filter call.I verified this locally with a small unit test: 25 Dag ids + mocked
http_session.postresulted in 25 POST calls, each with a differentresource_idclaim.I have not reproduced the full 10s
/dagspage load, but this per-Dag request pattern seems consistent with the reported slowdown when Keycloak calls have non-trivial latency.AWS auth manager seems to avoid this by batching authorization checks in
filter_authorized_dag_ids(). Would a similar batch path make sense for Keycloak?BTW, this may also need
area:providers/provider:keycloaklabels.stephen-bracken commentedon Jun 27, 2026
Hey @Andrushika thanks for taking a look. Yes I think in the keycloak case it should only be necessary to check access for each resource type, rather than each dag. Perhaps the caching layer should be moved from
filter_authorized_dag_ids()to_is_authorized()?Andrushika commentedon Jun 27, 2026
I don't think it is a good idea to only check permissions at the resource level... It would bypass the permission checking per
resource_id. The related permission check is added in #61137 as intended, so DAG-level authorization still seems necessary.I took a look at the source implementation. Parallelizing the N requests seems viable for reducing wall-clock latency.
Andrushika commentedon Jun 28, 2026
Hi @stephen-bracken, I have opened a PR for the parallelizing solution. I would appreciate it if you could help with testing!
stephen-bracken commentedon Jun 29, 2026
Hey @Andrushika I'll take a look at this later today