Skip to content

Commit 1976d79

Browse files
committed
refactor: Increase database connection pool
1 parent 5b32418 commit 1976d79

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

backend/common/core/config.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,5 +92,10 @@ def SQLALCHEMY_DATABASE_URI(self) -> PostgresDsn | str:
9292
EMBEDDING_SIMILARITY: float = 0.4
9393
EMBEDDING_TOP_COUNT: int = 5
9494

95+
PG_POOL_SIZE: int = 20
96+
PG_MAX_OVERFLOW: int = 30
97+
PG_POOL_RECYCLE: int = 3600
98+
PG_POOL_PRE_PING: bool = True
99+
95100

96101
settings = Settings() # type: ignore

backend/common/core/db.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,11 @@
22

33
from common.core.config import settings
44

5-
engine = create_engine(str(settings.SQLALCHEMY_DATABASE_URI), pool_size=20, max_overflow=30, pool_recycle=3600,
6-
pool_pre_ping=True)
5+
engine = create_engine(str(settings.SQLALCHEMY_DATABASE_URI),
6+
pool_size=settings.PG_POOL_SIZE,
7+
max_overflow=settings.PG_MAX_OVERFLOW,
8+
pool_recycle=settings.PG_POOL_RECYCLE,
9+
pool_pre_ping=settings.PG_POOL_PRE_PING)
710

811

912
def get_session():

0 commit comments

Comments
 (0)