First https request is much slower because of Creating threadLocal SSL context
- Dominant language
- Java
- Stars
- 9.5k
- Forks
- 2.3k
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 5
Description
**John** ([Bug 66248](https://bz.apache.org/bugzilla//show_bug.cgi?id=66248&redirect=false)):
When doing https request, the first request will be always much slower.
For example testing jmeter.apache.org 4 times in sequence gives response times: 1234, 110,110,130 ms
When using debug I see (removed lines in between):
2022-08-31 08:48:30,462 DEBUG o.a.j.p.h.s.HTTPHC4Impl: Start : sample https://jmeter.apache.org/ method GET followingRedirect false depth 0
2022-08-31 08:48:30,634 DEBUG o.a.j.u.JsseSSLManager: Creating threadLocal SSL context for: thread1 1-1
2022-08-31 08:48:31,312 DEBUG o.a.j.u.JsseSSLManager: Using threadLocal SSL context
for: thread1 1-1
2022-08-31 08:48:31,347 DEBUG o.a.h.c.s.SSLConnectionSocketFactory: Starting handshake
So creating the SSL context is taking 678ms. This is included in the response time of the first request.
For the next (same) request is it using the already created SSL context. So the response time of this request is much faster.
I have doubts if this "Creating threadLocal SSL context" should be part of the response time measured because it is not caused by the tested server/service.
For load testing maybe not a big issue (because a lot of requests). But we use jmeter also for monitoring. So we are staring jmeter, repeating 1 request 1-3 times and stop jmeter.
Created attachment [jmeter.log](https://apache.github.io/jmeter-bugzilla-attachments/48/66248/38381/jmeter.log): logfile with debug
Severity: normal
OS: All
Contributor guide
Research direction
Start at JsseSSLManager's thread-local SSL context creation and HTTPHC4Impl's sample timing, using the attached debug log as a reproduction reference. Trace where SSL initialization enters the first request's measured response time, then determine and verify the expected treatment of that setup cost.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- performance
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 32/100