From 78a7e85392352731ceaae3fbc0eb608054330cf5 Mon Sep 17 00:00:00 2001 From: Taha Yassine Kraiem Date: Fri, 10 Jun 2022 11:35:25 +0200 Subject: [PATCH] feat(api): changed connexion pool configuration feat(alerts): changed connexion pool configuration --- api/.env.default | 3 ++- api/Dockerfile.alerts | 1 + api/chalicelib/utils/pg_client.py | 4 +++- ee/api/.env.default | 3 ++- ee/api/Dockerfile.alerts | 1 + 5 files changed, 9 insertions(+), 3 deletions(-) diff --git a/api/.env.default b/api/.env.default index 30ff0b02d..aa14fc993 100644 --- a/api/.env.default +++ b/api/.env.default @@ -36,7 +36,8 @@ pg_password=asayerPostgres pg_port=5432 pg_user=postgres pg_timeout=30 -pg_minconn=45 +pg_minconn=20 +pg_maxconn=50 PG_RETRY_MAX=50 PG_RETRY_INTERVAL=2 put_S3_TTL=20 diff --git a/api/Dockerfile.alerts b/api/Dockerfile.alerts index 76e8c262a..59356aae8 100644 --- a/api/Dockerfile.alerts +++ b/api/Dockerfile.alerts @@ -6,6 +6,7 @@ COPY . . RUN pip install -r requirements.txt RUN mv .env.default .env && mv app_alerts.py app.py && mv entrypoint_alerts.sh entrypoint.sh ENV pg_minconn 2 +ENV pg_maxconn 10 ENV APP_NAME alerts # Add Tini diff --git a/api/chalicelib/utils/pg_client.py b/api/chalicelib/utils/pg_client.py index 1655a9579..2abc9f6c7 100644 --- a/api/chalicelib/utils/pg_client.py +++ b/api/chalicelib/utils/pg_client.py @@ -52,7 +52,9 @@ def make_pool(): except (Exception, psycopg2.DatabaseError) as error: print("Error while closing all connexions to PostgreSQL", error) try: - postgreSQL_pool = ORThreadedConnectionPool(config("pg_minconn", cast=int, default=20), 100, **PG_CONFIG) + postgreSQL_pool = ORThreadedConnectionPool(config("pg_minconn", cast=int, default=20), + config("pg_maxconn", cast=int, default=80), + **PG_CONFIG) if (postgreSQL_pool): print("Connection pool created successfully") except (Exception, psycopg2.DatabaseError) as error: diff --git a/ee/api/.env.default b/ee/api/.env.default index 8215908b2..7687566d7 100644 --- a/ee/api/.env.default +++ b/ee/api/.env.default @@ -45,7 +45,8 @@ pg_password=asayerPostgres pg_port=5432 pg_user=postgres pg_timeout=30 -pg_minconn=45 +pg_minconn=20 +pg_maxconn=50 PG_RETRY_MAX=50 PG_RETRY_INTERVAL=2 put_S3_TTL=20 diff --git a/ee/api/Dockerfile.alerts b/ee/api/Dockerfile.alerts index 6aec0f98b..3784045e0 100644 --- a/ee/api/Dockerfile.alerts +++ b/ee/api/Dockerfile.alerts @@ -7,6 +7,7 @@ COPY . . RUN pip install -r requirements.txt RUN mv .env.default .env && mv app_alerts.py app.py && mv entrypoint_alerts.sh entrypoint.sh ENV pg_minconn 2 +ENV pg_maxconn 10 ENV APP_NAME alerts # Add Tini