Documentation about how the default dispatcher reuses connections #2382
Replies: 2 comments 9 replies
-
Me again!
Usually, this configuration works perfectly for many cases, but for more complex use cases, you can alter it by passing an H2 support (H3 is not in Node.js yet) is experimental, and can be used by creating a client or agent with the flag Hope is pretty clear, but a PR is welcome to improve our documentation around those topics 🙂 |
Beta Was this translation helpful? Give feedback.
-
I'm also struggling with the way Undici's Agent is managing its connections. With Node's Agent, we had a clear documentation here, with Could you please explain what's the scheduling strategy here ? Is there a way ton configure it ? |
Beta Was this translation helpful? Give feedback.
-
When developing a high-performance server, one of the first things I'd do in
node-fetch
and similar was make sure I used anew Agent({ keepAlive: true })
agent to make sure that I wasn't re-establishing and then immediately destroying fresh TCP connections for every request.Now, particularly in the context of Node.js's built-in
fetch()
, my first question is: if and for how long are connections being kept alive and reused under the hood? Based on benchmarks, I'm guess it must be reusing connections in some way.In a browser implementation of
fetch()
, this is purely up to the browser to optimise, and they are normally very good at pooling connections and even using pipelining and HTTP/2/3 etc.In
undici
, these details are implemented by the dispatcher, and the in the case of build-infetch()
this is not something we can control or customise.So my question/request is: can we have documentation that explains how the default dispatcher behaves in terms of reusing connections, opportunistically using pipelining and HTTP/2/3 etc.
Like I mentioned this is one of the first questions when developing a high-performance server, and currently we need to dig into the code to find there is a default dispatcher, and examine the implementation learn what it is doing.
Beta Was this translation helpful? Give feedback.
All reactions