authentik icon indicating copy to clipboard operation
authentik copied to clipboard

2026.2 worker memory usage doubled vs 2025.12 (~500Mi → ~1020Mi)

Open AKhozya opened this issue 9 months ago • 12 comments

Description

After upgrading from 2025.12.4 to 2026.2.0, the ak worker process memory usage approximately doubled.

Environment

  • Previous version: 2025.12.4
  • New version: 2026.2.0
  • Deployment: Kubernetes (K3s), 2 worker replicas
  • Database: PostgreSQL 18.2 via PgBouncer (transaction pooling)
  • Redis: 8.6.0

Observed Memory Usage (Prometheus container_memory_working_set_bytes)

Version Pod Stable Memory
2025.12.4 worker-9pxtk ~466Mi
2025.12.4 worker-hsc9g ~511Mi
2026.2.0 worker-99nck ~1033Mi
2026.2.0 worker-pf2fq ~1023Mi
2026.2.0 worker-fgjlf ~1014Mi
2026.2.0 worker-xvg9d ~1014Mi

The server (ak server) pods did not show a similar increase — they stayed in the 500-800Mi range on both versions.

Impact

We had to increase the worker container memory limit from 1200Mi to 1500Mi. The old 1200Mi limit triggered ContainerMemoryNearLimit alerts at 85% (1023Mi/1200Mi).

Notes

  • The jump is too large (~500Mi) to be explained by the Python 3.14 runtime alone
  • Possible contributors: new Django apps loaded (WS-Federation, Fleet connector, SSF, lifecycle management, endpoint devices), new chunked_queryset usage, django_postgres_cache backend
  • May not be the bug pe se, but I was suprised + monioring caught memory consumption was near limit

AKhozya avatar Feb 24 '26 22:02 AKhozya

I dont think the new django apps should cause this, chunked_queryset might be part of the cause

cc @rissson

BeryJu avatar Feb 24 '26 23:02 BeryJu

Deployed via Helm is experiencing the same issue,after the upgrade, memory usage increased, causing workers to continuously restart. The memory had to be increased to 1GB

resources:
    limits:
      cpu: 500m
      memory: 2Gi
    requests:
      cpu: 100m
      memory: 1Gi
NAME                                            CPU(cores)   MEMORY(bytes)
authentik-3ra3ywjmb6z-server-55758d44f8-hjm52   20m          674Mi
authentik-3ra3ywjmb6z-server-55758d44f8-kj97w   18m          687Mi
authentik-3ra3ywjmb6z-server-55758d44f8-nnpnn   19m          696Mi
authentik-3ra3ywjmb6z-worker-5dc49c4dbd-8kmng   79m          970Mi
authentik-3ra3ywjmb6z-worker-5dc49c4dbd-mx2rx   48m          972Mi
authentik-3ra3ywjmb6z-worker-5dc49c4dbd-wcgnt   100m         970Mi
Image

dalamudx avatar Feb 25 '26 10:02 dalamudx

Same on my k8s deployment (Helm). Worker memory increased by roughly +110% after upgrading from 2025.12.4 to 2026.2.0 Image

gabrielcosi avatar Feb 25 '26 12:02 gabrielcosi

Same here with normal docker install, high memory usage and dead service due to constant 100% load on the system, high load maybe because of out of memory, didnt check before i rolled back to 2025.12.

sjansen1 avatar Feb 25 '26 19:02 sjansen1

I was also forced to rollback. 3 workers in HA I couldn't handle it.

Armhole1225 avatar Feb 25 '26 21:02 Armhole1225

Same here deployed with helm.. Even increasing memory, when stressing a bit the server, server and workers pod crashes.. Performance was not super in previous versions, but with this release, I am facing several pod crashes. I created a simple script to create 30 users, and set membership, and the server crashes in 10 seconds..

marcportabellaclotet-mt avatar Feb 26 '26 12:02 marcportabellaclotet-mt

While we investigate what caused this, I do just want to note that most deployments will be perfectly fine with a single instance of the worker container; tasks will end up in a queue and if no worker is running they will stay there until a worker is running again.

BeryJu avatar Feb 26 '26 12:02 BeryJu

Looking at our internal instances, I can confirm the memory increase. In our instance running off of a stable release the upgrade I can see the increase right after updating:

Image

On our instance running off of main there's also a bump, however the usage went back down and has been back down since:

Image

BeryJu avatar Feb 26 '26 13:02 BeryJu

Just to add some extra information, the server pod also crashes when creating 50 users and setting group membership with automation. It creates a huge number of psql connections, and postgresql runs out of available connections.

{"domain_url": null, "event": "dropping exception", "exc": "OperationalError('connection failed: connection to server at \"192.168.130.237\", port 5432 failed: FATAL:  remaining connection slots are reserved for roles with the SUPERUSER attribute')", "level": "debug", "logger": "authentik.lib.sentry", "pid": 49, "schema_name": "public", "timestamp": "2026-02-26T13:13:43.137587"}

I also used pgbouncer with max connection limit to 200, and connections exhausted.

marcportabellaclotet-mt avatar Feb 26 '26 13:02 marcportabellaclotet-mt

I also noticed weird failures occurring after upgrading to 2026.2 -- I suspect the memory usage is more of a symptom than a cause, because I also experienced similar issues with Postgres running out of connections as @marcportabellaclotet-mt mentioned.

Even after raising the connection limit on my cnpg pooler, I couldn't scale beyond a single server and worker instance until I created a dedicated pgpooler for Authentik and used the transaction pool mode instead of session . Which might be a better practice anyways because I did see the occasional instability prior to upgrading but never often enough to really make a stink about. I was able to scale back up to 3 servers and 3 workers after adding the dedicated pooler

dubyatp avatar Feb 26 '26 14:02 dubyatp

we're still investigating this. Our current suspects are either the bump of python from 3.13 to 3.14, or a dependency upgrade. In the meantime, if you have set AUTHENTIK_WORKER__PROCESSES to a higher value than 1, you can reduce it to alleviate memory consumption, bumping AUTHENTIK_WORKER__THREADS to something higher. Tasks will process slower, but the whole process should use less memory overall.

rissson avatar Feb 26 '26 16:02 rissson

I just wanted to add a datapoint to this thread. The title of the issue is "memory usage doubled", but I saw memory usage go from about 800 MB to 12 GB (!), which is way worse than doubled. After upgrading to 2026.2.1, memory usage is back down to approximately the same level it was before.

Image

quentinmit avatar Mar 24 '26 05:03 quentinmit