Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions backend/druks/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,19 @@ def create_engine_from_url(database_url: str):
# at the lifecycle boundary (the API session dependency, the worker session
# wrapper) so a failed unit of work rolls back instead of leaving partial
# writes. Model methods ``flush()``; the boundary commits. Low pool_timeout
# because a checkout wait blocks the event loop.
return create_engine(database_url, pool_pre_ping=True, pool_timeout=5)
# because a checkout wait blocks the event loop. The pool serves every
# concurrent run's steps plus request handling at once: a modest steady
# pool, with overflow doing the burst work — overflow connections open on
# demand and close on return, so the ceiling is high while idle cost is
# not. Ceiling 50 keeps the appliance (with DBOS's two engines at 20 each)
# inside Postgres's default 100 connections.
return create_engine(
database_url,
pool_pre_ping=True,
pool_timeout=5,
pool_size=20,
max_overflow=30,
)


def get_session(engine) -> Session:
Expand Down