From 562ad647c10256760295b385581e8191b3f5cc8d Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Tue, 23 Jul 2024 11:40:55 -0400 Subject: [PATCH] Limit Celery's Redis connections (#1164) This change adds a `MAX_CELERY_CONNECTIONS` environment variable, which defaults to `60`. --- config/settings.py | 3 +++ docs/env_vars.md | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/config/settings.py b/config/settings.py index 294ed1bf..ba3581fa 100755 --- a/config/settings.py +++ b/config/settings.py @@ -254,6 +254,9 @@ CELERY_ACCEPT_CONTENT = ["application/json"] CELERY_TASK_SERIALIZER = "json" CELERY_RESULT_SERIALIZER = "json" CELERY_TIMEZONE = "UTC" +CELERY_BROKER_TRANSPORT_OPTIONS = { + "max_connections": env.int("MAX_CELERY_CONNECTIONS", default=60) +} CACHES = { "default": { diff --git a/docs/env_vars.md b/docs/env_vars.md index dc83f004..87926dc3 100644 --- a/docs/env_vars.md +++ b/docs/env_vars.md @@ -75,3 +75,7 @@ This project uses environment variables to configure certain aspects of the appl ### `CI` - If set, will set SITE_ID to 1 in `settings.py`. + +### `MAX_CELERY_CONNECTIONS` + +- If set, will set the maximum number of connections to the Celery in `settings.py`. Defaults to 60.