Skip to content

armgit / letta

Public Imported from GitHub
0

Platform for stateful agents: AI with advanced memory that can learn and self-improve over time.

feat: Tune down pg pool size params and switch connection picking to LIFO (#2299)

Matthew Zhoua16a812275fb
diff --git a/letta/server/db.py b/letta/server/db.py
index 32dbb13ef..5204390e7 100644
--- a/letta/server/db.py
+++ b/letta/server/db.py
@@ -84,6 +84,8 @@ class DatabaseRegistry:
pool_timeout=settings.pg_pool_timeout,
pool_recycle=settings.pg_pool_recycle,
echo=settings.pg_echo,
+ pool_pre_ping=settings.pool_pre_ping,
+ pool_use_lifo=settings.pool_use_lifo,
# connect_args={"client_encoding": "utf8"},
)
@@ -132,6 +134,8 @@ class DatabaseRegistry:
pool_timeout=settings.pg_pool_timeout,
pool_recycle=settings.pg_pool_recycle,
echo=settings.pg_echo,
+ pool_pre_ping=settings.pool_pre_ping,
+ pool_use_lifo=settings.pool_use_lifo,
)
self._async_engines["default"] = async_engine
diff --git a/letta/settings.py b/letta/settings.py
index a1cc61f65..20326eeea 100644
--- a/letta/settings.py
+++ b/letta/settings.py
@@ -179,11 +179,13 @@ class Settings(BaseSettings):
pg_host: Optional[str] = None
pg_port: Optional[int] = None
pg_uri: Optional[str] = default_pg_uri # option to specify full uri
- pg_pool_size: int = 80 # Concurrent connections
- pg_max_overflow: int = 30 # Overflow limit
+ pg_pool_size: int = 25 # Concurrent connections
+ pg_max_overflow: int = 10 # Overflow limit
pg_pool_timeout: int = 30 # Seconds to wait for a connection
pg_pool_recycle: int = 1800 # When to recycle connections
pg_echo: bool = False # Logging
+ pool_pre_ping: bool = True # Pre ping to check for dead connections
+ pool_use_lifo: bool = True
# multi agent settings
multi_agent_send_message_max_retries: int = 3