Skip to content

Java 11 HTTP client reuse covers ordinary connections - #2584

Merged
jhy merged 2 commits into
masterfrom
httpclient-reuse
Aug 24, 2026
Merged

jhy merged 2 commits into
masterfrom
httpclient-reuse

Conversation

@jhy

@jhy jhy commented Aug 24, 2026

Copy link
Copy Markdown
Owner

Requests via Jsoup.newSession() already reused their HttpClient. This extends that reuse to independent Jsoup.connect(...) calls, so repeated requests do not create a new transport client and its threads each time.

Custom authentication and SSL contexts remain isolated, and proxy selection remains per request.

Fixes: #2516

Requests from Jsoup.newSession() already reused their HttpClient.
This extends that reuse to independent Jsoup.connect(...) calls, so repeated
requests do not create a new transport client and its threads each time.

Custom authentication and SSL contexts remain isolated, and proxy selection
remains per request.

Fixes: #2516
@jhy

jhy commented Aug 24, 2026

Copy link
Copy Markdown
Owner Author

Both runs used JDK 21.0.12, 200 requests, and concurrency 32 where applicable.

Workload Server connections HttpClient threads
Independent sequential requests 200 → 1 379 → 4
Session sequential requests 1 → 1 4 → 4
Independent concurrent requests 200 → 32 357 → 40
Session concurrent requests 63 → 32 126 → 44

So this really improves both thread / GC, and ability for connection keep-alive, when using independent requests vs session requests.

@jhy
jhy merged commit 868f2eb into master Aug 24, 2026
21 checks passed
@jhy
jhy deleted the httpclient-reuse branch August 24, 2026 05:15
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.

Review HttpClient's thread use under heavy request load

1 participant