goauthentik / goauthentik/authentik
High concurrency (30k users) causes >4000 DB connections and rapid service crash
- Dominant language
- Python
- Stars
- 25.6k
- Forks
- 2k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 644
Description
### Describe the bug
Under high concurrent load (approximately 30,000 concurrent users), Authentik crashes rapidly. During this traffic spike, the active database connections shoot up to over 4,000, which overwhelms the database cluster and causes Authentik web/worker instances to fail completely.
### How to reproduce
1. Deploy Authentik using Docker across 3 VMs.
2. Connect to a PostgreSQL cluster consisting of 1 Read/Write (Primary) and 2 Read-Only nodes.
3. Configure Authentik with high worker/thread counts (see environment details below).
4. Simulate or experience a concurrent login load of ~30,000 users.
5. Observe database connections spiking >4,000 followed by an immediate crash of Authentik services.
### Expected behavior
Authentik should gracefully handle high concurrent requests, efficiently manage or pool database connections, and maintain service stability without exhausting database connection limits.
### Screenshots
Environment details:
- Authentik Infrastructure: 3 VMs (Each VM: 32 vCPU, 20 GB RAM)
- Database Infrastructure: Cluster with 1 Read/Write, 2 Read-Only (Each Node: 40 vCPU, 80 GB RAM)
Partial Authentik Configuration:
```
AUTHENTIK_WEB__WORKERS=48
AUTHENTIK_WEB__THREADS=8
AUTHENTIK_WORKER__PROCESSES=8
AUTHENTIK_WORKER__THREADS=4
```
### Additional context
With 3 VMs, the total theoretical web threads are 48×8×3=1,152 threads, but we see database connections exceeding 4,000.
We are looking for guidance on:
1. What are the recommended configurations for AUTHENTIK_WEB__WORKERS and threads for our hardware specifications (32 vCPU, 20 GB RAM per VM)?
2. How should we properly implement connection pooling or tune the database to prevent connection exhaustion under a 30,000 concurrent user load?
### Deployment Method
Docker
### Version
2026.5.3
### Relevant log output
```shell
```
Contributor guide
Assessment
This issue has not been assessed yet.