Skip to content

Commit

Permalink
fix: Increase connection pool to 20 concurrent database connections
Browse files Browse the repository at this point in the history
Due to the asynchronous nature of FastAPI and the number of requests,
it can happen that we have to handle more than the default of 5 requests
at the same time.

In addition, reduce the pool timeout to 5. The goal is to fail requests
if they can't get a database session within 5 seconds instead of spawning
a queue with wait times of 30 seconds, which can lead to a blocking backend.
  • Loading branch information
MoritzWeber0 committed Oct 24, 2024
1 parent 7963611 commit ce5cb51
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions backend/capellacollab/core/database/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
engine = sa.create_engine(
config.database.url,
connect_args={"connect_timeout": 5, "options": "-c timezone=utc"},
pool_size=20,
pool_timeout=5,
)
SessionLocal = orm.sessionmaker(autocommit=False, autoflush=False, bind=engine)

Expand Down

0 comments on commit ce5cb51

Please sign in to comment.