Ssl – Apache TLS (SSL) Performance

apache-2.4httpsperformancessltls

We are running a fairly powerful dedicated server with a Xeon CPU, 32GB RAM, and RAID SSDs running Centos 6. Yet, we are still seeing HTTPS add over 100ms to our page download time. Is there anything we can do to even get a 20ms speed up?

Here are Apache settings:

SSLHonorCipherOrder on

SSLRandomSeed startup file:/dev/urandom 512
SSLRandomSeed connect file:/dev/urandom 512

SSLCipherSuite ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-EC$
SSLProxyCipherSuite ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECD$

SSLProtocol all -SSLv3 -SSLv2
SSLProxyProtocol all -SSLv3 -SSLv2

SSLPassPhraseDialog  builtin
SSLSessionCache        "shmcb:/var/run/ssl_scache(5120000)"
SSLSessionCacheTimeout  300

SSLUseStapling On

SSLStaplingCache "shmcb:/var/run/ssl_stapling(128000)"
SSLStaplingReturnResponderErrors off

SSLStaplingStandardCacheTimeout 3600
SSLStaplingErrorCacheTimeout 600
SSLStaplingResponderTimeout 5

Best Answer

HTTPS does slow your website down despite all claims to the contrary. This is because the client and server need to negotiate the SSL/TLS ciphers before it can start. However after that, the slowdown is negligible for most sites, and there are massive benefits to SSL.

Additionally the default is http, so someone entering that for a https-only site will need redirecting to the https version leading to another round trip.

100ms is actually not that bad a slowdown for initial connection and, as I say, after that the connection will be established and so there will be no slowdown. So first up, although initial connection speed is important, browsing around a site is also very important and here you shouldn't be affected by the 100ms slowdown.

Your SSL/TLS config actually looks pretty good, both in terms of security and performance. You are using modern and speedy ciphers and suites (though your cipher suite is very restrictive to new browsers only and if that's intentional then you might as well turn off TLSv1 and TLSv1.1 as well), have SSL Caching set up (to save clients renegotiating an SSL session for each connection), and SSL Stapling set up (to save the client an extra lookup to check the validity of your cert).

However some things I can suggest are below. These may reduce impact of using https but will not reduce that initial 100ms connection delay:

  1. Ensure Keep-Alives are turned on for the server (should be by default but best to double check). You should ensure you do not see a "Connection: close" header in the response. Without Keep-Alives your SSLCache is pointless.

  2. Increase your SSLSessionCacheTimeout from 300 seconds or 5 minutes. If on your site and browsing around you could easily go outside that. You've already limited the size of your SSLSessionCache so no harm in increasing this timeout to something higher.

  3. Implement HSTS to tell the browser your site always prefers https (even if the user enters no protocol in their browser address bar - or even if they enter http). This will save the initial redirect.

  4. HTTP/2 will help with https connection speed as you no loner use parallel connections for that but, more importantly, will help performance in other ways. It is still experimental for Apache though (though seems stable enough to me).

I would also advise you regularly run your server through https://www.ssllabs.com/ssltest/index.html to test your SSL/TLS config as things constantly change in this space as new vulnerabilities are found.