Skip to content

Add TTL cache with single-flight dedup to Keycloak filter_authorized_dag_ids - #63184

Merged
vincbeck merged 6 commits into
apache:mainfrom
stegololz:feature/keycloak-cache-filter
Mar 10, 2026
Merged

Add TTL cache with single-flight dedup to Keycloak filter_authorized_dag_ids#63184
vincbeck merged 6 commits into
apache:mainfrom
stegololz:feature/keycloak-cache-filter

Conversation

@stegololz

Copy link
Copy Markdown
Contributor

Performance improvement for the Keycloak auth manager. Loading the
home/DAG UI pages triggers multiple filter_authorized_dag_ids calls
for the same user and DAG set. Without caching, every call hits
Keycloak individually, making the UI slow.

This adds a TTL cache on filter_authorized_dag_ids so only the first
call hits Keycloak and subsequent identical calls return from cache.
A single-flight deduplication layer prevents the thundering herd problem
where N concurrent cache misses all fire N identical Keycloak requests
before any can populate the cache.

The cache TTL is currently hardcoded at 30s. I'm open to discussion on
the right value or whether it should be configurable.

This is a pragmatic solution to reduce per-resource check overhead.
Keycloak's UMA permission endpoint currently requires individual
queries per resource (keycloak/keycloak#45311). If a better approach
emerges — upstream or otherwise — this can be revisited.

related: keycloak/keycloak#45311


Was generative AI tooling used to co-author this PR?
  • Yes — Claude Opus 4.6

@stegololz stegololz closed this Mar 9, 2026
@stegololz
stegololz force-pushed the feature/keycloak-cache-filter branch from f2d60e7 to 9d0800f Compare March 9, 2026 14:43
@stegololz stegololz reopened this Mar 9, 2026
Comment thread providers/keycloak/src/airflow/providers/keycloak/auth_manager/cache.py Outdated
Comment thread providers/keycloak/src/airflow/providers/keycloak/auth_manager/cache.py Outdated
@stegololz
stegololz marked this pull request as ready for review March 9, 2026 17:21
@stegololz
stegololz requested a review from bugraoz93 as a code owner March 9, 2026 17:21
@stegololz
stegololz force-pushed the feature/keycloak-cache-filter branch from 3f5c917 to 37d3bc5 Compare March 10, 2026 08:25
@vincbeck
vincbeck merged commit 429f5c6 into apache:main Mar 10, 2026
88 checks passed
dominikhei pushed a commit to dominikhei/airflow that referenced this pull request Mar 11, 2026
Pyasma pushed a commit to Pyasma/airflow that referenced this pull request Mar 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants