diff --git a/docs/env.md b/docs/env.md index cdde8b8d..df57ad0b 100644 --- a/docs/env.md +++ b/docs/env.md @@ -46,6 +46,8 @@ These are the environment variables you can set for the `impress-backend` contai | DB_NAME | Name of the database | impress | | DB_PASSWORD | Password to authenticate with | pass | | DB_PORT | Port of the database | 5432 | +| DB_PSYCOPG_POOL_MIN_SIZE | The psycopg min pool size | 4 | +| DB_PSYCOPG_POOL_MAX_SIZE | The psycopg max pool size | None | | DB_USER | User to authenticate with | dinum | | DJANGO_ALLOWED_HOSTS | Allowed hosts | [] | | DJANGO_CELERY_BROKER_TRANSPORT_OPTIONS | Celery broker transport options | {} | diff --git a/src/backend/impress/settings.py b/src/backend/impress/settings.py index b75da3d4..64a043fe 100755 --- a/src/backend/impress/settings.py +++ b/src/backend/impress/settings.py @@ -99,6 +99,19 @@ class Base(Configuration): "localhost", environ_name="DB_HOST", environ_prefix=None ), "PORT": values.Value(5432, environ_name="DB_PORT", environ_prefix=None), + "OPTIONS": { + # https://www.psycopg.org/psycopg3/docs/api/pool.html#psycopg_pool.ConnectionPool + "pool": { + "min_size": values.IntegerValue( + 4, environ_name="DB_PSYCOPG_POOL_MIN_SIZE", environ_prefix=None + ), + "max_size": values.IntegerValue( + None, + environ_name="DB_PSYCOPG_POOL_MAX_SIZE", + environ_prefix=None, + ), + } + }, } } DEFAULT_AUTO_FIELD = "django.db.models.AutoField"