Skip to content

Commit 72f8014

Browse files
jrvb-rlclaude
andauthored
perf: increase undici HTTP/2 pool from 4x64 to 20x128 streams (#801)
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 43fcd45 commit 72f8014

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

src/lib/undici-fetch.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,12 @@ import { MultipartBody } from '../_shims/MultipartBody';
3737
import { type Fetch } from '../core';
3838

3939
const KEEP_ALIVE_TIMEOUT_MS = 10 * 60 * 1000;
40-
// Bound the pool to a few TLS sessions per origin and multiplex many H2 streams
41-
// over each. 4 x 64 = 256 concurrent requests in flight before undici queues the rest.
42-
const H2_MAX_CONNECTIONS = 4;
43-
const H2_MAX_CONCURRENT_STREAMS = 64;
40+
// Bound the pool to several TLS sessions per origin and multiplex H2 streams over
41+
// each. The server typically advertises MAX_CONCURRENT_STREAMS=100-128; we use 128
42+
// per connection to match. 20 x 128 = 2560 concurrent requests in flight before
43+
// undici queues the rest.
44+
const H2_MAX_CONNECTIONS = 20;
45+
const H2_MAX_CONCURRENT_STREAMS = 128;
4446

4547
// One module-scoped default dispatcher, reused across requests: a bounded HTTP/2 pool
4648
// with keep-alive. `allowH2` negotiates h2 over TLS via ALPN and transparently falls

0 commit comments

Comments
 (0)