Skip to content

Conversation

@ryanpesek
Copy link

@ryanpesek ryanpesek commented Nov 22, 2025

Attempt at optimizing applications api for users with a lot of groups and access to a lot of applications

Details

In my testing, the prefetch_related and select_related and modifications to the list() applications functions all brought moderate improvements. However, the caching of the user data instead of serializing the user again for each time get_launch_url is called brought massive improvements. Old behavior was 10s+ for a page of 100 applications and with all of these changes combined the new performance is 1-2s

Checklist

  • Local tests pass (ak test authentik/)
  • The code has been formatted (make lint-fix)

If an API change has been made

  • The API schema has been updated (make gen-build)

If changes to the frontend have been made

  • The code has been formatted (make web)

If applicable

  • The documentation has been updated
  • The documentation has been formatted (make docs)

@netlify
Copy link

netlify bot commented Nov 22, 2025

Deploy Preview for authentik-docs ready!

Name Link
🔨 Latest commit 2e6cb78
🔍 Latest deploy log https://app.netlify.com/projects/authentik-docs/deploys/69273888bc9dbe00080ef556
😎 Deploy Preview https://deploy-preview-18330--authentik-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify
Copy link

netlify bot commented Nov 22, 2025

Deploy Preview for authentik-integrations ready!

Name Link
🔨 Latest commit 2e6cb78
🔍 Latest deploy log https://app.netlify.com/projects/authentik-integrations/deploys/69273888536bc80008bb5691
😎 Deploy Preview https://deploy-preview-18330--authentik-integrations.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@codecov
Copy link

codecov bot commented Nov 23, 2025

Codecov Report

❌ Patch coverage is 86.36364% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 92.57%. Comparing base (d211ea1) to head (2e6cb78).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
authentik/core/api/applications.py 81.25% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #18330      +/-   ##
==========================================
- Coverage   92.98%   92.57%   -0.41%     
==========================================
  Files         894      894              
  Lines       48919    48938      +19     
==========================================
- Hits        45486    45306     -180     
- Misses       3433     3632     +199     
Flag Coverage Δ
e2e 44.23% <86.36%> (-1.23%) ⬇️
integration 23.12% <18.18%> (-0.06%) ⬇️
unit 91.10% <86.36%> (+<0.01%) ⬆️
unit-migrate 91.15% <86.36%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ryanpesek ryanpesek changed the title core: optimize applications core: optimize list applications Nov 24, 2025
@rissson rissson self-assigned this Nov 24, 2025
@rissson rissson moved this from Todo to Needs review in authentik Core Nov 24, 2025
@rissson rissson requested a review from BeryJu November 26, 2025 17:24
Comment on lines +530 to +535
# qs = qs.select_related(f"provider__{subclass}__backchannel_application")
# qs = qs.select_related(f"provider__{subclass}__authentication_flow")
# qs = qs.select_related(f"provider__{subclass}__authorization_flow")
# qs = qs.select_related(f"provider__{subclass}__invalidation_flow")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# qs = qs.select_related(f"provider__{subclass}__backchannel_application")
# qs = qs.select_related(f"provider__{subclass}__authentication_flow")
# qs = qs.select_related(f"provider__{subclass}__authorization_flow")
# qs = qs.select_related(f"provider__{subclass}__invalidation_flow")

@rissson rissson force-pushed the optimize-applications-api branch from b8197e7 to 2e6cb78 Compare November 26, 2025 17:27
@rissson rissson requested review from a team as code owners November 26, 2025 17:27
@rissson rissson changed the base branch from version-2025.10 to main November 26, 2025 17:27
@rissson rissson added the backport/version-2025.10 Add this label to PRs to backport changes to version-2025.10 label Nov 26, 2025
@rissson rissson added this to the Release 2025.10.3 milestone Nov 26, 2025
@BeryJu BeryJu removed request for a team November 27, 2025 13:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:backend backport/version-2025.10 Add this label to PRs to backport changes to version-2025.10

Projects

Status: Needs review

Development

Successfully merging this pull request may close these issues.

3 participants