goauthentik / authentik

The authentication glue you need.
https://goauthentik.io
Other
12.59k stars 847 forks source link

Celery max_tasks_per_child setting #6839

Open a-gerhard opened 12 months ago

a-gerhard commented 12 months ago

Describe your question/ The authentik worker has max_tasks_per_child set to 1 (source code). This means that a new worker process is spawned for each task, meaning that all the imports need to be repeated for all tasks. It has nothing to do with the number of processes executed in parallel. For many small tasks, this may present a significant overhead.

According to celery documentation, this setting is only useful to avoid memory leaks. Even in such a scenario, I don't think that it makes sense to replace the worker for each task, but only after having executed a number of tasks (see here).

Is there any reason for this decision? Otherwise, I would suggest setting it higher (e.g., 50 or 100) or even disabling the limit (set to 0).

Version and Deployment (please complete the following information):

BeryJu commented 12 months ago

https://github.com/goauthentik/authentik/commit/a987846c760d64e5e460972b36ebc05cfe44c8eb#diff-6ba5277649943a55f3754d0d3aed97882392a9b130c2518cd8afa3f2d75080adR331 it seems like this is supposed to be set to 50 and is being set to 1 erroneously

a-gerhard commented 12 months ago

The worker's setting is actually set to 50, but the pool is set to 1. Looking at the PIDs of the workers, it appears that the pool setting is overriding the worker settings. Your MR should fix this.