From 41c7560739fe9663541b52ca21ea663b94a153bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=B5=84=E2=B5=8E=E2=B5=89=E2=B5=94=E2=B5=93=E2=B5=9B=20?= =?UTF-8?q?=E2=B4=B0=E2=B5=8E=E2=B4=B0=E2=B5=A3=E2=B5=89=E2=B5=96?= Date: Thu, 30 Nov 2023 17:55:26 +0100 Subject: [PATCH] fix(api): reduce the number of connection used by pgpool. There should be no use of much more than two pgconnection per worker, even in the case where there is "some" asynchronous code interleaved between synchronous code. The new async code is using its own pg pool that has max=four. ref: See max_size at https://www.psycopg.org/psycopg3/docs/api/pool.html#the-connectionpool-class --- api/chalicelib/utils/pg_client.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api/chalicelib/utils/pg_client.py b/api/chalicelib/utils/pg_client.py index 750db3c1b..d216f6399 100644 --- a/api/chalicelib/utils/pg_client.py +++ b/api/chalicelib/utils/pg_client.py @@ -64,8 +64,8 @@ def make_pool(): except (Exception, psycopg2.DatabaseError) as error: logging.error("Error while closing all connexions to PostgreSQL", error) try: - postgreSQL_pool = ORThreadedConnectionPool(config("PG_MINCONN", cast=int, default=20), - config("PG_MAXCONN", cast=int, default=80), + postgreSQL_pool = ORThreadedConnectionPool(config("PG_MINCONN", cast=int, default=4), + config("PG_MAXCONN", cast=int, default=8), **PG_CONFIG) if (postgreSQL_pool): logging.info("Connection pool created successfully")