TLS has exactly one performance problem: it is not used widely enough.

Everything else can be optimized.

Data delivered over an unencrypted channel is insecure, untrustworthy, and trivially intercepted. We owe it to our users to protect the security, privacy, and integrity of their data — all data must be encrypted while in flight and at rest. Historically, concerns over performance have been the common excuse to avoid these obligations, but today that is a false dichotomy. Let's dispel some myths.

CPU & latency costs

The process of establishing and communicating over an encrypted channel introduces additional computational costs. First, there is the asymmetric (public key) encryption used during the TLS handshake. Then, once a shared secret is established, symmetric encryption takes over.

# upgrade to latest
$> openssl version
OpenSSL 1.0.2g  01 Mar 2016

# run benchmarks
$> openssl speed sha
$> openssl speed ecdh

Good news is, modern hardware has made great improvements to help minimize these costs, and what once may have required additional hardware can now be done efficiently by the CPU.

On our production frontend machines, SSL/TLS accounts for less than 1% of the CPU load, less than 10 KB of memory per connection and less than 2% of network overhead. Many people believe that SSL/TLS takes a lot of CPU time and we hope the preceding numbers will help to dispel that.
- Adam Langley, Google "Overclocking SSL"

We have deployed TLS at a large scale using both hardware and software load balancers. We have found that modern software-based TLS implementations running on commodity CPUs are fast enough to handle heavy HTTPS traffic load without needing to resort to dedicated cryptographic hardware.
- Doug Beaver, Facebook "HTTP2 Expression of Interest"

Elliptic Curve Diffie-Hellman (ECDHE) is only a little more expensive than RSA for an equivalent security level… In practical deployment, we found that enabling and prioritizing ECDHE cipher suites actually caused negligible increase in CPU usage. HTTP keepalives and session resumption mean that most requests do not require a full handshake, so handshake operations do not dominate our CPU usage. We find 75% of Twitter’s client requests are sent over connections established using ECDHE. The remaining 25% consists mostly of older clients that don’t yet support the ECDHE cipher suites.
- Jacob Hoffman-Andrews, Twitter "Forward Secrecy at Twitter"

Before the client and the server can begin exchanging application data over TLS, the encrypted tunnel must be negotiated, which introduces additional roundtrips for each new connection. However, we don't have to incur the cost of a full handshake in every case: TLS resumption and TLS False Start decrease the cost to a single roundtrip for new and returning clients.

A well tuned TLS deployment can make an enormous positive difference in the user experience, as well as in your operational costs. Some of the most critical features and concepts:

To deliver the best performance, run down the TLS performance checklist and use a tool like Qualys SSL Server Test to scan your server for common configuration and security flaws.

High Performance Browser Networking

What every developer should know about networking and web performance.

Read HPBN online

Server performance

TLS exposes many different knobs and new config flags on every server. Our goal here is not to provide an exhaustive list (consult server docs for that), but to highlight status of important performance-oriented features: resumption, stapling, false start (requires ALPN and forward secrecy), and support for the HTTP/2 protocol.

  Session identifiers Session tickets OCSP stapling Dynamic record sizing ALPN Forward secrecy HTTP/2
Apache yes yes yes yes yes yes yes
ATS yes yes yes dynamic yes yes yes
bud no yes yes static yes yes no
Brocade vTM yes no yes no yes yes yes
F5 BIG-IP yes yes yes yes yes yes yes
H2O yes yes yes static (1.4k) yes yes yes
HAProxy yes yes yes dynamic yes yes no
Hitch yes yes yes no yes yes yes
IIS yes yes yes no yes yes yes
NetScaler yes no no no yes yes yes
NGINX yes yes yes static (16k) yes yes yes
node.js yes yes optional optional yes yes yes
Go yes yes optional yes yes yes yes
nghttpx yes yes yes dynamic yes yes yes
ShimmerCat yes no no yes yes yes yes

Your favorite server missing, or found an error? Open a pull request!

CDN & PaaS performance

Using a CDN allows us to terminate the connection close to the user, which can significantly reduce the cost of TCP and TLS handshake - see early termination. For best results you should be using a CDN to serve both static and dynamic content.

  Session identifiers Session tickets OCSP stapling Dynamic record sizing ALPN Forward secrecy HTTP/2
Akamai yes yes no configurable (static) yes yes yes
AWS ELB (Classic) yes yes no no no yes no
AWS ELB (Application) yes yes no no yes yes yes
AWS CloudFront no yes yes no yes yes yes
BelugaCDN yes yes yes dynamic yes yes yes
CDN77 yes yes yes dynamic yes yes yes
CloudFlare yes yes yes dynamic yes yes yes
ChinaNetCenter yes yes no no no yes no
EdgeCast no yes yes no yes yes no
Fastly yes yes yes dynamic yes yes yes
Google App Engine yes yes no dynamic yes yes yes
Heroku yes yes no no no yes no
Imperva Incapsula yes yes no no yes yes yes
Instart Logic yes yes no configurable (static) yes yes yes
KeyCDN yes yes yes configurable (static) yes yes yes
Limelight yes yes no no no yes no
MaxCDN yes yes yes no yes yes yes
Netlify yes yes yes dynamic yes yes yes
QUANTIL yes yes no no no yes no

Your favorite CDN or PaaS provider missing, or found an error? Open a pull request!


What about benchmarks?

Quality of implementation matters — no argument there — and you should do your due diligence. That said, you need to test on your own hardware and with realistic traffic patterns to get an accurate picture of what works best for your specific workload. Don't trust outdated benchmarks, update your OpenSSL libraries, update your server, and run the tests.

TLS operational costs are still higher, right?

Not necessarily. Once you enable and optimize your TLS stack you're also well on your way to deploying HTTP/2. Unlike HTTP/1.1, HTTP/2 requires only a single connection per origin, which means fewer sockets, memory buffers, TLS handshakes, and so on. As a result, it may well be the case that you will be able to handle more users with fewer resources.

TLS still adds an extra RTT; can we fix that?

One possible route is to leverage TCP Fast Open, which would allow us to send the ClientHello within the TCP SYN packet — that would cut another RTT. In the meantime, both TLS 1.3 and QUIC are experimenting with "zero-RTT" handshake mechanisms. See QUIC crypto doc and this GDL episode for a general introduction to QUIC.

Which ciphersuite should I be using?

Mozilla maintains a wiki page with a recommended ciphersuite list and server configuration tips.

If TLS False Start is enabled, do I need resumption?

Both resumption and TLS False Start eliminate an extra roundtrip from the TLS handshake. However, resumption also allows you to skip the asymmetric handshake crypto by reusing parameters from a previous session — this saves CPU cycles. In other words, yes you need both.

I run a multi-server deployment. Any tips?

Ensure you have a shared session cache to get a good cache hit rate on resumed sessions across different servers. Also, ensure you expire and rotate your sessions and session ticket keys in a secure manner, especially when forward secrecy is enabled.

What about certificate costs?

You can get free certificates for any use from Let’s Encrypt. If you need EV verification, then you will have to pay a bit extra. Use your favorite search engine to look for and evaluate the available options. The security and integrity of your visitors' data is worth every penny!

What about Elliptic Curve Cryptography (ECC) certificates?

ECC certificates offer stronger security and smaller certificates - e.g. a 256-bit ECC key is equivalent to a 3072-bit RSA key. However, many clients do not support ECDSA, which means that the server should support both RSA and ECDSA, and some popular servers do not support dual certificate deployments. Consult the documentation of your server to see if RSA+ECDSA is a supported option.

What about CRIME and BREACH attacks?

CRIME is an attack against compression at the TLS layer. All modern user agents disable TLS compression, but it is still recommended that you disable TLS compression on your server. BREACH, on the other hand, is an attack against compression on top of TLS (e.g. HTTP compression) and must be mitigated both at the server and application levels - read more.

How do I migrate my existing site to HTTPS?

Checkout the HTTPS Everywhere presentation (slides) from Google I/O to learn the best practices and the steps to safely migrate your existing content to HTTPS.

Why do we need HTTPS everywhere?

Every unencrypted HTTP request reveals information about user’s behavior. Today, there is no such thing as insensitive web traffic - read more.

Where can I learn more about TLS performance?