Skip to content

litellm_fix(perf): skip global router_settings in per-request Router creation#20133

Closed
shin-bot-litellm wants to merge 1 commit intoBerriAI:mainfrom
shin-bot-litellm:litellm_fix_global_router_settings_redundancy
Closed

litellm_fix(perf): skip global router_settings in per-request Router creation#20133
shin-bot-litellm wants to merge 1 commit intoBerriAI:mainfrom
shin-bot-litellm:litellm_fix_global_router_settings_redundancy

Conversation

@shin-bot-litellm
Copy link
Contributor

@shin-bot-litellm shin-bot-litellm commented Jan 31, 2026

Problem

┌─────────────────────────────────────────────────────────────┐
│                     STARTUP                                 │
│  Global router_settings → Applied to shared llm_router ✅   │
└─────────────────────────────────────────────────────────────┘
                              │
                              ▼
┌─────────────────────────────────────────────────────────────┐
│                   EVERY REQUEST                             │
│  _get_hierarchical_router_settings() returns global settings│
│           ↓                                                 │
│  Creates NEW Router (redundant - already on shared!) ❌     │
└─────────────────────────────────────────────────────────────┘

Issue: Global router_settings in DB trigger per-request Router creation, but they're already applied to the shared llm_router at startup.

Fix

Remove global settings lookup from _get_hierarchical_router_settings():

- # 3. Try global router_settings
- db_router_settings = await prisma_client.db.litellm_config.find_first(...)
- return db_router_settings.param_value
+ # Skip global - already on shared router from startup
+ return None

Now only key/team-specific settings create per-request Routers.

Related

@vercel
Copy link

vercel bot commented Jan 31, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
litellm Error Error Jan 31, 2026 8:41am

Request Review

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Global settings already on shared router from startup.
Removes redundant per-request Router creation.

Issue BerriAI#19921
@shin-bot-litellm
Copy link
Contributor Author

Closing - need deeper investigation first. The fix may be incomplete (DB query still happens on every request). Will reopen with proper fix after full analysis.

cursor bot pushed a commit that referenced this pull request Feb 4, 2026
This documents the root causes and solutions for the 'All connection attempts failed'
error that users experienced after upgrading to v1.81.x:

1. Per-request Router creation with expensive Prometheus initialization (fixed in #20087)
2. Redundant Router creation for global settings (fixed in #20133)
3. DB connection pool exhaustion with IAM auth (fixed in #13140)
4. Connection pool configuration recommendations

Includes SQL queries to diagnose/clean router_settings and config recommendations.

Co-authored-by: Ishaan Jaff <ishaan-jaff@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants