Skip to Content

SSL/TLS, SNI and deregistration delay

HTTPS on load balancers with ACM certificates, serving many domains with SNI, security policies, and connection draining.

SSL/TLS basics

An SSL/TLS certificate lets traffic between clients and the load balancer be encrypted in transit (in-flight encryption).

  • SSL (Secure Sockets Layer) is the old name. TLS (Transport Layer Security) is the newer version that's actually used today, but people still say "SSL certificate".
  • Public certificates are issued by certificate authorities (CAs) such as DigiCert, GlobalSign, Let's Encrypt, or Amazon (through ACM).
  • Certificates expire and must be renewed.

Certificates on a load balancer

Example

A common setup: users connect with HTTPS (encrypted) over the internet to the load balancer, which decrypts and sends HTTP to the instances over the private VPC network. That's SSL termination at the load balancer: the instances don't spend CPU on encryption. If rules require it, the load balancer can re-encrypt to HTTPS targets instead.

  • The load balancer uses an X.509 certificate (an SSL/TLS server certificate).
  • Manage certificates with AWS Certificate Manager (ACM): free public certificates that renew automatically. Third-party certificates can also be uploaded.
  • An HTTPS listener needs a default certificate, and can have a list of extra certificates for more domains.
  • A security policy chooses which TLS versions and ciphers clients may use, for example allowing older versions for legacy clients, or only TLS 1.2 and 1.3.

Server Name Indication (SNI)

The client asks for www.mycorp.com; the HTTPS listener picks the matching certificate from its list and routes to the www.mycorp.com target group The client asks for www.mycorp.com; the HTTPS listener picks the matching certificate from its list and routes to the www.mycorp.com target group

Many websites, many certificates, one listener.

SNI solves the problem of loading multiple certificates onto one server that hosts several websites.

  1. In the first step of the TLS handshake, the client says which hostname it wants, for example www.mycorp.com.
  2. The load balancer picks the matching certificate from its list (or uses the default one if none matches).
  3. A listener rule on the host header sends the request to the right target group.

SNI works with ALB, NLB (TLS listeners) and CloudFront. It does not work with the Classic Load Balancer.

Certificates per load balancer type

  • Classic Load Balancer: only one certificate. Several hostnames with different certificates need several CLBs.
  • Application Load Balancer: many listeners with many certificates, using SNI.
  • Network Load Balancer: many TLS listeners with many certificates, using SNI.

Deregistration delay (connection draining)

The load balancer lets a deregistering instance finish in-flight requests for up to 300 seconds by default while new connections go to the other instances The load balancer lets a deregistering instance finish in-flight requests for up to 300 seconds by default while new connections go to the other instances

Let old requests finish before removing an instance.

When an instance is being deregistered (scale-in, deployment) or becomes unhealthy, cutting it off at once would break requests still in progress.

  • The feature is called Connection Draining on a CLB and Deregistration Delay on ALB and NLB.
  • The load balancer stops sending new requests to that instance, but gives in-flight requests time to complete.
  • From 1 to 3,600 seconds, 300 seconds by default; 0 turns it off.
  • Set it low (for example 30 seconds) if the requests are short, so deployments and scale-in don't wait five minutes for nothing.

Exam tips

  • "HTTPS for the website, free certificate that renews itself" → ACM certificate on the load balancer's HTTPS listener.
  • "Host several HTTPS domains on one load balancer" → ALB or NLB with multiple certificates and SNI.
  • "Classic Load Balancer with several domains" → needs one CLB per certificate (or migrate to ALB).
  • "Support old clients' TLS versions" → choose a security policy that allows them.
  • "In-flight requests fail during scale-in or deployments" → increase the deregistration delay. "Deployments take 5 minutes per instance for short requests" → lower it.

Common traps

  • "SNI works on every load balancer." Not on the Classic Load Balancer.
  • "Remember to renew the load balancer's ACM certificate every year." ACM renews its certificates automatically while they're in use (with DNS validation); uploaded third-party certificates are the ones that must be renewed manually.

Check yourself

An HTTPS lab needs an owned domain name (to validate an ACM certificate), so instead:

AWS documentation

On this page

Open notes

Spotted a mistake?

These notes are open source. Suggest a fix, or star the repo if they helped you.

Suggest an edit

For AI agents: llms.txt · llms-full.txt