diff --git a/authentik/core/management/commands/worker.py b/authentik/core/management/commands/worker.py index e400e83ab..b22187efe 100644 --- a/authentik/core/management/commands/worker.py +++ b/authentik/core/management/commands/worker.py @@ -29,7 +29,7 @@ class Command(BaseCommand): no_color=False, quiet=True, optimization="fair", - autoscale=(3, 1), + autoscale=(CONFIG.get_int("worker.concurrency"), 1), task_events=True, beat=options.get("beat", True), schedule_filename=f"{tempdir}/celerybeat-schedule", diff --git a/authentik/lib/default.yml b/authentik/lib/default.yml index 76792f9c8..793bece13 100644 --- a/authentik/lib/default.yml +++ b/authentik/lib/default.yml @@ -111,3 +111,6 @@ web: # No default here as it's set dynamically # workers: 2 threads: 4 + +worker: + concurrency: 2 diff --git a/authentik/root/settings.py b/authentik/root/settings.py index 4bec86fd9..d484d2ecb 100644 --- a/authentik/root/settings.py +++ b/authentik/root/settings.py @@ -332,7 +332,7 @@ LOCALE_PATHS = ["./locale"] CELERY = { "task_soft_time_limit": 600, "worker_max_tasks_per_child": 50, - "worker_concurrency": 2, + "worker_concurrency": CONFIG.get_int("worker.concurrency"), "beat_schedule": { "clean_expired_models": { "task": "authentik.core.tasks.clean_expired_models", diff --git a/website/docs/installation/configuration.mdx b/website/docs/installation/configuration.mdx index 400c13108..9f90666d2 100644 --- a/website/docs/installation/configuration.mdx +++ b/website/docs/installation/configuration.mdx @@ -363,6 +363,16 @@ Configure how many gunicorn threads a worker processes should have (see https:// Defaults to 4. +### `AUTHENTIK_WORKER__CONCURRENCY` + +:::info +Requires authentik 2023.9.0 +::: + +Configure Celery worker concurrency for authentik worker (see https://docs.celeryq.dev/en/latest/userguide/configuration.html#worker-concurrency). This essentially defines the number of worker processes spawned for a single worker. + +Defaults to 2. + ## Custom python settings To modify additional settings further than the options above allow, you can create a custom python file and mount it to `/data/user_settings.py`. This file will be loaded on startup by both the server and the worker. All default settings are [here](https://github.com/goauthentik/authentik/blob/main/authentik/root/settings.py)