New-user iteration does not reset TLS session state (parity gap with JMeter's HTTP client)
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 45/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Attiva
- Stack tecnologico
- java
- Ambito
- networking, performance, security, testing-qa
Direzione di ricerca
Inizia con HTTP2Sampler.iterationStart() e clearUserStores(), quindi esamina HTTP2JettyClient vicino a closeIdleConnections() e NewUserIterationConnectionResetTest. Esegui prima la misurazione TLS descritta in regime stazionario per determinare se le iterazioni riutilizzano un SSLContext e riprendono effettivamente gli handshake. Il lavoro è completo quando il divario pratico è stato stabilito o escluso e, se necessario, il comportamento di reset proposto è coperto da un test reale di iterazione TLS.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Summary
When a Thread Group has Same user on each iteration unchecked, JMeter simulates a new visitor and
its own HttpClient4 sampler drops the thread's TLS session state, so the next iteration performs a
full TLS handshake. This plugin does not: Jetty owns the SSLContext, and its client session cache
lives for the whole life of the per-thread client, across every iteration.
Measured consequence: the client's TLS session cache is untouched by our new-user iteration reset.
Whether that translates into an actually resumed handshake in a steady-state run is the first thing
to establish - see Open question below, it is not a formality.
This was split out of #171. That issue was about an NPE in Jetty's buffer pool; while comparing our
iteration reset against JMeter's, this gap showed up. It is independent and much smaller in impact.
Why it matters
A resumed TLS handshake is roughly one RTT cheaper than a full one, and far cheaper in server CPU.
If a test configured for a new visitor per iteration silently resumes the previous visitor's session,
it under-reports both handshake latency and the server-side cost of accepting new users - which for
many TLS load tests is precisely what is being measured.
What JMeter does (verified in 5.6.3 sources)
HTTPHC4Impl.resetStateIfNeeded()
calls((JsseSSLManager) SSLManager.getInstance()).resetContext()on a new-user iteration, gated
byhttpclient.reset_state_on_thread_group_iteration(defaulttrue).JsseSSLManager.resetContext()
doesthreadlocal.remove().- That ThreadLocal holds one
SSLContextper thread, because
https.sessioncontext.shared
defaults tofalse. JsseSSLManager.getContext()
recreates it on next use, with an empty session cache.- Every HC4 TLS socket asks for it again:
HttpSSLProtocolSocketFactory.getSSLSocketFactory(),
reached fromLazyLayeredConnectionSocketFactory.
Worth knowing: setting https.sessioncontext.shared=true makes JMeter's own reset a no-op, since
resetContext() returns immediately in that case. Whatever we implement should probably honour the
same two properties rather than inventing new ones.
What the plugin does today
JMeterJettySslContextFactory extends Jetty's SslContextFactory.Client and injects JMeter's
key/trust managers, but the SSLContext itself is built and owned by Jetty inside the factory. A
factory is created per ClientConnector, and HTTP2JettyClient.createClientConnector() is called
from seven places (main, quic, noh3, http1, h2c-upgrade, h2c, http11-fallback), so a single
per-thread client can hold several independent SSLContexts, each with its own session cache, alive
for the life of the client.
JMeter's SSLManager.resetContext() therefore has no effect on us: it resets a ThreadLocal that
Jetty never consults again after building its context.
Evidence
Measured with a throwaway probe (HTTP/1.1 over TLS against the suite's own ServerBuilder server,
driving HTTP2Sampler.sample() and a real iterationStart with __jmv_SAME_USER=false), counting
session ids in SslContextFactory.getSslContext().getClientSessionContext() across every
SslContextFactory bean of every Jetty client on the thread:
sample 1 ok=true code=200
cached client TLS sessions after sample 1: 3 total [3 in 2899a8db]
cached client TLS sessions after new-user reset: 3 total [3 in 2899a8db] <-- untouched
sample 2 ok=true
cached client TLS sessions after sample 2: 6 total [3 in 2899a8db, 3 in 74518890]
Two things to take from it:
- The new-user reset does not touch the TLS session cache. Same count, same
SSLContext
identity before and after. That is the gap, and it is measured rather than inferred. - A second
SSLContextappears for the second sample. So there really are multiple client
SSLContexts per thread at runtime, and any fix has to walk all of them, not just the main
client's.
Open question - do this first
Observation 2 above cuts both ways, and it is why this issue should not start with a patch.
The second sample landed on a different SSLContext than the first. If that is what normally
happens across iterations, then the second handshake could not have resumed anything - it had an
empty cache - and the practical impact of this gap is smaller than the theory suggests, or even nil
in that path. The most likely explanation is that the first HTTPS sample populated the HTTP/1.1-only
cache (or the destination removal in the new-user reset sent the next sample down the fallback
connector), so iteration 2 used a different Jetty client than iteration 1.
So, before implementing anything, establish whether a steady-state run actually resumes sessions
across iterations:
- Run several iterations and log, per iteration, which Jetty client and
SSLContextserved the
sample, plus the session-cache count. If iterations settle on oneSSLContext, resumption is
live and the gap is real in practice. - Confirm whether the handshake is actually abbreviated, not just that a cached session exists.
Session-id equality between connections is a reliable indicator on TLS 1.2 but not on TLS 1.3,
where JSSE creates a freshSSLSessionper connection even when resuming from a ticket. Options:
pin the probe to TLS 1.2 for a coarse answer, or read ajavax.net.debug=ssl:handshaketrace for
the real one. Do not rely on session-id equality alone. - Only then decide whether the fix is worth its cost.
If the measurement shows iterations do not share an SSLContext in practice, the right outcome for
this issue may be a documentation note rather than code.
Proposal, if the measurement confirms the gap
Three levers exist in Jetty 12.1.11, verified present with javap on jetty-util-12.1.11.jar:
| Lever | Effect | Cost |
|---|---|---|
getSslContext().getClientSessionContext() -> getIds() + SSLSession.invalidate() |
Drops cached sessions, per iteration, surgically | Low. Must be applied to every SslContextFactory of every client |
setSslSessionCacheSize(0) / setSslSessionTimeout(...) |
Prevents resumption at the source | Disables resumption always, not only between iterations - wrong default for a returning-visitor test |
reload(Consumer<SslContextFactory>) |
Rebuilds the SSLContext; the closest analogue to what JMeter does |
High: rebuilds key/trust managers, so it re-reads JMeter's keystore every iteration, and loadJMeterKeyStore can prompt for a password |
Recommended shape:
- Add a method on
HTTP2JettyClientnext tocloseIdleConnections()- the new-user iteration reset
added in the #171 fix - that walkshttpClient.getContainedBeans(SslContextFactory.class)for
every Jetty client it owns and invalidates each context's client sessions. - Call it from
HTTP2Sampler.clearUserStores()under the existing
RESET_STATE_ON_THREAD_GROUP_ITERATIONflag, so it is governed by the same property as the rest
of the new-user reset, exactly like JMeter's. - Honour
https.sessioncontext.shared=trueas a skip, matching JMeter, where its own reset is a
no-op. - Test it the way
NewUserIterationConnectionResetTesttests the connection reset: real TLS server,
realiterationStart, assert the session cache is empty afterwards - and, if the handshake-type
measurement above works out, assert the handshake is full.
Do not rebuild the connectors or the clients per iteration. That is what
HTTP2Sampler.iterationStart() deliberately avoids, since recreating them would dominate fast
iterations.
Out of scope
- TLS 1.3 early data / 0-RTT. Jetty's client does not use it by default, so it is not part of this.
- The buffer-pool NPE of #171, which is fixed separately.
- Lingua principale
- Java
- Stelle
- 51
- Fork
- 30
- Merge medio
- 2g 22h
- PR unite (30g)
- 8
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di Blazemeter/jmeter-http-plugin
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
Blazemeter/jmeter-http-plugin#186 ·
-
bug
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
Blazemeter/jmeter-http-plugin#187 ·
-
enhancement
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
Blazemeter/jmeter-http-plugin#48 · 1 reazione ·
Tutte le issue di Blazemeter/jmeter-http-plugin
Issue simili
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
0. Needs triage bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
nextcloud/notes-android#3469 ·
I maintainer di solito rispondono entro 1 giorno
-
installation sdk usability
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
beehive-lab/TornadoVM#1356 ·
I maintainer di solito rispondono entro 1 giorno
-
0. Needs triage enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
I maintainer di solito rispondono entro 1 giorno
-
good first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 67/100
davidfercas/opendcanard#34 ·