Skip to content

Multi Team: /dags screen is very slow to load with multiple teams #69041

Closed

Description

@stephen-bracken

Under which category would you file this issue?

Airflow Core

Apache Airflow version

3.2.1

What happened and how to reproduce it?

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

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

Activity

  1. added
    kind:bug
    needs-triage
    on Jun 26, 2026
  2. added
    area:API
    area:UI
    on Jun 26, 2026
  3. Andrushika commented on Jun 26, 2026

    @Andrushika
    Contributor

    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.

  4. stephen-bracken commented on Jun 27, 2026

    @stephen-bracken
    ContributorAuthor

    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()?

  5. Andrushika commented on Jun 27, 2026

    @Andrushika
    Contributor

    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.

  6. Andrushika commented on Jun 28, 2026

    @Andrushika
    Contributor

    Hi @stephen-bracken, I have opened a PR for the parallelizing solution. I would appreciate it if you could help with testing!

  7. stephen-bracken commented on Jun 29, 2026

    @stephen-bracken
    ContributorAuthor

    Hey @Andrushika I'll take a look at this later today

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:APIarea:UIarea:providerskind:bugneeds-triageprovider:keycloak

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions