-
Notifications
You must be signed in to change notification settings - Fork 0
feat: add cluster management #39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -23,6 +23,16 @@ import { recordError, requiresApproval } from "./utils.js"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { closeLastOutputItem } from "./closeOutputItem.js"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { modelCallCounter, modelCallDuration } from "../../lib/metrics.js"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Shared undici Agent per worker process — avoids creating a new connection pool per request. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Configurable via UPSTREAM_MAX_CONNECTIONS (connections per origin) and UPSTREAM_KEEP_ALIVE_TIMEOUT_MS. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const sharedDispatcher = new Agent({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| allowH2: true, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| connections: parseInt(process.env.UPSTREAM_MAX_CONNECTIONS || "128", 10), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pipelining: 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| keepAliveTimeout: parseInt(process.env.UPSTREAM_KEEP_ALIVE_TIMEOUT_MS || "30000", 10), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| connectTimeout: parseInt(process.env.UPSTREAM_CONNECT_TIMEOUT_MS || "30000", 10), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+26
to
+33
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Shared undici Agent per worker process — avoids creating a new connection pool per request. | |
| // Configurable via UPSTREAM_MAX_CONNECTIONS (connections per origin) and UPSTREAM_KEEP_ALIVE_TIMEOUT_MS. | |
| const sharedDispatcher = new Agent({ | |
| allowH2: true, | |
| connections: parseInt(process.env.UPSTREAM_MAX_CONNECTIONS || "128", 10), | |
| pipelining: 1, | |
| keepAliveTimeout: parseInt(process.env.UPSTREAM_KEEP_ALIVE_TIMEOUT_MS || "30000", 10), | |
| connectTimeout: parseInt(process.env.UPSTREAM_CONNECT_TIMEOUT_MS || "30000", 10), | |
| function getFiniteIntegerEnv(name: string, fallback: number): number { | |
| const rawValue = process.env[name]; | |
| if (rawValue === undefined) { | |
| return fallback; | |
| } | |
| const parsedValue = Number(rawValue); | |
| return Number.isFinite(parsedValue) && Number.isInteger(parsedValue) ? parsedValue : fallback; | |
| } | |
| // Shared undici Agent per worker process — avoids creating a new connection pool per request. | |
| // Configurable via UPSTREAM_MAX_CONNECTIONS (connections per origin) and UPSTREAM_KEEP_ALIVE_TIMEOUT_MS. | |
| const sharedDispatcher = new Agent({ | |
| allowH2: true, | |
| connections: getFiniteIntegerEnv("UPSTREAM_MAX_CONNECTIONS", 128), | |
| pipelining: 1, | |
| keepAliveTimeout: getFiniteIntegerEnv("UPSTREAM_KEEP_ALIVE_TIMEOUT_MS", 30000), | |
| connectTimeout: getFiniteIntegerEnv("UPSTREAM_CONNECT_TIMEOUT_MS", 30000), |
Uh oh!
There was an error while loading. Please reload this page.