From ba93bcf20b1cedfbd98f94f1ffe7c1b1c6afde03 Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Thu, 12 Mar 2026 08:32:54 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7(backend)=20enable=20psycopg-pool?= =?UTF-8?q?=20allowing=20configuring=20min=20and=20max=20size?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We enable the pool option on the DB configuration. We want to allow the configuration of the min and max sixe in a first time. They can be configured using the settings DB_PSYCOPG_POOL_MIN_SIZE and DB_PSYCOPG_POOL_MAX_SIZE. They have their default value to 4 and None. --- docs/env.md | 2 ++ src/backend/impress/settings.py | 13 +++++++++++++ 2 files changed, 15 insertions(+) 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"