feat(api): changed connexion pool configuration

feat(alerts): changed connexion pool configuration
This commit is contained in:
Taha Yassine Kraiem 2022-06-10 11:35:25 +02:00
parent 3cb45b7a90
commit 78a7e85392
5 changed files with 9 additions and 3 deletions

View file

@ -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

View file

@ -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

View file

@ -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:

View file

@ -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

View file

@ -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