root: make Celery worker concurrency configurable (#6837)

* root: made Celery worker concurrency configurable

* core: fixed Celery worker command to set autoscaling options to account for worker concurrency setting

* Update website/docs/installation/configuration.md

Signed-off-by: Jens L. <jens@beryju.org>
Signed-off-by: Jens Langhammer <jens@goauthentik.io>

---------

Signed-off-by: Jens L. <jens@beryju.org>
Signed-off-by: Jens Langhammer <jens@goauthentik.io>
Co-authored-by: Jens L <jens@beryju.org>
This commit is contained in:
Alissa Gerhard 2023-09-26 12:37:22 +02:00 committed by GitHub
parent e807f9f12c
commit 0e5952650b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 15 additions and 2 deletions

View File

@ -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",

View File

@ -111,3 +111,6 @@ web:
# No default here as it's set dynamically
# workers: 2
threads: 4
worker:
concurrency: 2

View File

@ -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",

View File

@ -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)