Skip to content

perf(node-http-handler): cache 100-continue agents at module level#1986

Closed
trivikr wants to merge 2 commits into
mainfrom
node-http-handler-cache-agent
Closed

perf(node-http-handler): cache 100-continue agents at module level#1986
trivikr wants to merge 2 commits into
mainfrom
node-http-handler-cache-agent

Conversation

@trivikr

@trivikr trivikr commented Apr 29, 2026

Copy link
Copy Markdown
Contributor

Issue #, if available:

Improving HttpHandler performance before benchmarking with undici handler

Description of changes:

Replaces per-request Agent creation for 100-continue requests with lazily initialized module-level singletons.

Workloads that send many 100-continue requests (e.g., S3 PutObject) were creating a new Agent per request, causing significant GC pressure. A single cached agent per protocol (HTTP/HTTPS) is now reused across all handler instances.


By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@trivikr trivikr requested a review from a team as a code owner April 29, 2026 22:12

@kuhe kuhe left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reusing an agent could resurface the bug that originally necessitated creating a new agent.

We should prove that the original issue (internal repro is available) is fixed before merging this change.

If it is fixed, creating a separate agent may be unnecessary to begin with.

In any case this is partially mitigated by the byte length check before enabling 100-continue in S3.

@kuhe kuhe closed this Jun 8, 2026
@trivikr trivikr deleted the node-http-handler-cache-agent branch June 8, 2026 17:36
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