fix(embedder): bound OpenAI HTTP connection pools - #4475
Open
ranxi2001 wants to merge 2 commits into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Current main already reuses one async OpenAI client per event loop. Those clients, and the synchronous client, still let the OpenAI SDK create its default HTTP transport. In the locked SDK that means up to 1000 connections and 100 idle keepalive connections, well above OpenViking's default embedding concurrency of 10. The embedder also had no
close()implementation for its sync client or cached async clients.This change gives every OpenAI and Azure embedding client an SDK-default HTTP transport whose connection and keepalive limits follow the existing
max_concurrentsetting. Validated configuration now rejects values below one, while direct embedder construction preserves the existing one-request fallback instead of creating a pool that can only time out. The SDK timeout behavior and five-second keepalive expiry remain unchanged.The service now closes and clears its embedder after queue workers and vector storage stop, so the sync client and all event-loop-scoped async clients are released during normal shutdown.
Human Involvement
Related Issue
Fixes #4462
Type of Change
Changes Made
embedding.max_concurrent < 1and normalize direct-constructor values to one;Testing
Local checks:
PoolTimeout; andgit diff --checkpassed on the changed files.Checklist
Screenshots (if applicable)
Not applicable; this backend connection-management change has no visual output.
Additional Notes
The issue's
keepalive_expiry=infdescription does not match the currently locked OpenAI SDK, which uses five seconds. The oversized1000/100connection limits are still present and are the behavior this PR bounds. Validation used a controlled local server, not a sustained production llama.cpp workload. Pool sizes and timeouts are not added as new configuration fields, and other embedding providers are unchanged.