https://issues.apache.org/bugzilla/show_bug.cgi?id=55023
Bug ID: 55023
Summary: SSL Context reuse feature (51380) adversely affects
non-ssl request performance/throughput
Product: JMeter
Version: 2.9
Hardware: All
OS: Linux
Status: NEW
Severity: regression
Priority: P2
Component: HTTP
Assignee: [email protected]
Reporter: [email protected]
The enhancement to control the reuse of cached SSL Context instances between
iterations (51380) is causing a performance bottleneck with http (non-ssl)
requests. In HTTPSamplerBase the following code is executed regardless of
whether the HTTPS protocol is being used or not:
@Override
public void testIterationStart(LoopIterationEvent event) {
if (!USE_CACHED_SSL_CONTEXT) {
JsseSSLManager sslMgr = (JsseSSLManager) SSLManager.getInstance();
sslMgr.resetContext();
notifySSLContextWasReset();
}
}
With JVM profiling enabled on the JMeter process (adding:
"-agentlib:hprof=cpu=samples,interval=2,depth=10,monitor=y,thread=n" to the JVM
command line) I noticed that even though I was running a script using only HTTP
requests (no SSL in the mix), hot spots were identified in SSL code paths:
TRACE 300823:
sun.security.provider.X509Factory.getFromCache(X509Factory.java:203)
sun.security.provider.X509Factory.engineGenerateCertificate(X509Factory.java:93)
java.security.cert.CertificateFactory.generateCertificate(CertificateFactory.java:339)
sun.security.provider.JavaKeyStore.engineLoad(JavaKeyStore.java:747)
sun.security.provider.JavaKeyStore$JKS.engineLoad(JavaKeyStore.java:55)
java.security.KeyStore.load(KeyStore.java:1214)
sun.security.ssl.TrustManagerFactoryImpl.getCacertsKeyStore(TrustManagerFactoryImpl.java:221)
sun.security.ssl.TrustManagerFactoryImpl.engineInit(TrustManagerFactoryImpl.java:51)
javax.net.ssl.TrustManagerFactory.init(TrustManagerFactory.java:250)
sun.security.ssl.SSLContextImpl.engineInit(SSLContextImpl.java:83)
TRACE 300844:
java.io.FileInputStream.read(FileInputStream.java:Unknown line)
java.io.DataInputStream.readInt(DataInputStream.java:387)
sun.security.provider.JavaKeyStore.engineLoad(JavaKeyStore.java:667)
sun.security.provider.JavaKeyStore$JKS.engineLoad(JavaKeyStore.java:55)
java.security.KeyStore.load(KeyStore.java:1214)
sun.security.ssl.TrustManagerFactoryImpl.getCacertsKeyStore(TrustManagerFactoryImpl.java:221)
sun.security.ssl.TrustManagerFactoryImpl.engineInit(TrustManagerFactoryImpl.java:51)
javax.net.ssl.TrustManagerFactory.init(TrustManagerFactory.java:250)
sun.security.ssl.SSLContextImpl.engineInit(SSLContextImpl.java:83)
javax.net.ssl.SSLContext.init(SSLContext.java:283)
Moreover, when the SSL Context Reset code is executed, in the Apache HTTPClient
sampler Implementations, open connections are closed even if they are not
established with SSL (HTTPHC4ClientImpl.closeThreadLocalConnections()) thus
making "Keep Alive" ineffective.
As a simple fix I added a check on the protocol in use like the following:
@Override
public void testIterationStart(LoopIterationEvent event) {
if (!USE_CACHED_SSL_CONTEXT &&
getProtocol().equalsIgnoreCase(HTTPConstants.PROTOCOL_HTTPS)) {
JsseSSLManager sslMgr = (JsseSSLManager) SSLManager.getInstance();
sslMgr.resetContext();
notifySSLContextWasReset();
}
}
With keep-alive enabled HTTP request throughput increases by around 500% in my
environment. I'm not certain, however, if this is the "most correct" fix
because it is based on whether the last request executed in the iteration is
SSL or not.
--
You are receiving this mail because:
You are the assignee for the bug.