From ec16e734c6b6c9ff72f693e16a54c97007e3f7ad Mon Sep 17 00:00:00 2001 From: rakesh-krishna-a-s Date: Thu, 31 Aug 2023 19:49:37 +0530 Subject: [PATCH] set pool size to 20 --- main.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/main.py b/main.py index a0242eda2..8a349e2d5 100644 --- a/main.py +++ b/main.py @@ -69,8 +69,13 @@ else: db_url = f'postgresql://{db_username}:{db_password}@{database_url}/{db_name}' -engine = create_engine(db_url) -# SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine) +engine = create_engine(db_url, + pool_size=20, # Maximum number of database connections in the pool + max_overflow=50, # Maximum number of connections that can be created beyond the pool_size + pool_timeout=30, # Timeout value in seconds for acquiring a connection from the pool + pool_recycle=1800, # Recycle connections after this number of seconds (optional) + pool_pre_ping=False, # Enable connection health checks (optional) + ) # app.add_middleware(DBSessionMiddleware, db_url=f'postgresql://{db_username}:{db_password}@localhost/{db_name}') app.add_middleware(DBSessionMiddleware, db_url=db_url)