The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
Fix: Clarify database_connection_pool_limit applies per worker, not per instance (#18780)
Alexsander Hamir98d7a428b64c
diff --git a/docs/my-website/docs/proxy/configs.md b/docs/my-website/docs/proxy/configs.mdindex bc2f6a13362..a5674bf2bc5 100644--- a/docs/my-website/docs/proxy/configs.md+++ b/docs/my-website/docs/proxy/configs.md@@ -576,10 +576,31 @@ custom_tokenizer:```yamlgeneral_settings:- database_connection_pool_limit: 10 # sets connection pool for prisma client to postgres db (default: 10, recommended: 10-20)+ database_connection_pool_limit: 10 # sets connection pool per worker for prisma client to postgres db (default: 10, recommended: 10-20)database_connection_timeout: 60 # sets a 60s timeout for any connection call to the db```+**How to calculate the right value:**++The connection limit is applied **per worker process**, not per instance. This means if you have multiple workers, each worker will create its own connection pool.++**Formula:**+```+database_connection_pool_limit = MAX_DB_CONNECTIONS ÷ (number_of_instances × number_of_workers_per_instance)+```++**Example:**+- Your database allows a maximum of **100 connections**+- You're running **1 instance** of LiteLLM+- Each instance has **8 workers** (set via `--num_workers 8`)++Calculation: `100 ÷ (1 × 8) = 12.5`++Since you shouldn't use 12.5, round down to **10** to leave a safety buffer. This means:+- Each of the 8 workers will have a connection pool limit of 10+- Total maximum connections: 8 workers × 10 connections = 80 connections+- This stays safely under your database's 100 connection limit+## Extrasdiff --git a/docs/my-website/docs/proxy/prod.md b/docs/my-website/docs/proxy/prod.mdindex c5612b752b7..9216b0fbf30 100644--- a/docs/my-website/docs/proxy/prod.md+++ b/docs/my-website/docs/proxy/prod.md@@ -19,7 +19,11 @@ general_settings:master_key: sk-1234 # enter your own master key, ensure it starts with 'sk-'alerting: ["slack"] # Setup slack alerting - get alerts on LLM exceptions, Budget Alerts, Slow LLM Responsesproxy_batch_write_at: 60 # Batch write spend updates every 60s- database_connection_pool_limit: 10 # limit the number of database connections to = MAX Number of DB Connections/Number of instances of litellm proxy (Around 10-20 is good number)+ database_connection_pool_limit: 10 # connection pool limit per worker process. Total connections = limit × workers × instances. Calculate: MAX_DB_CONNECTIONS / (instances × workers). Default: 10.++:::warning+**Multiple instances:** If running multiple LiteLLM instances (e.g., Kubernetes pods), remember each instance multiplies your total connections. Example: 3 instances × 4 workers × 10 connections = 120 total connections.+:::# OPTIONAL Best Practicesdisable_error_logs: True # turn off writing LLM Exceptions to DBdiff --git a/litellm/proxy/common_utils/performance_utils.py b/litellm/proxy/common_utils/performance_utils.pyindex 987efb82922..f9537f85e2b 100644--- a/litellm/proxy/common_utils/performance_utils.py+++ b/litellm/proxy/common_utils/performance_utils.py@@ -160,7 +160,9 @@ def wrap_function_with_line_profiler(module: Any, function_name: str) -> bool:Returns:True if wrapping was successful, False otherwise"""- if not enable_line_profiler():+ try:+ enable_line_profiler() # May raise ImportError if not available+ except ImportError:return Falseif _line_profiler is None: