System Design AI

TLS Handshakes in System Design Interviews: When to Use Them and What to Say

TLS (Transport Layer Security) is the protocol that creates an encrypted, authenticated channel between two endpoints before any application data is exchanged. In a system design interview you should treat it as the "secure handshake" that guarantees confidentiality and integrity for the traffic flowing through your architecture.

Why TLS matters in a concrete system

Imagine you are designing a global e-commerce platform that serves browsers, mobile apps, and third-party partners. All of those clients send credit-card numbers, session tokens, and personal data. Without TLS, anyone with network access could sniff the packets or inject malicious responses. The TLS handshake solves two problems at once:

  1. Confidentiality – encrypts the payload so passive eavesdroppers cannot read it.
  2. Authentication – proves the server (and optionally the client) is who it claims to be, preventing man-in-the-middle attacks.

In practice, the handshake is the first thing that happens after a TCP connection is established between the client and the edge load balancer or API gateway.

Step-by-step TLS 1.3 handshake (simplified)

Below is a minimal flow that still captures the essential messages. It follows one connection from the first message to the first encrypted request.

StepMessagePurpose
1ClientHelloAnnounces TLS version, supported cipher suites, and a random nonce.
2ServerHelloPicks a cipher suite and sends its own random nonce and key share. Everything after this message is encrypted.
3Certificate and CertificateVerifyThe server sends its certificate chain and a signature over the handshake transcript, proving it holds the private key. If client authentication is required, the client sends the same pair.
4FinishedBoth sides exchange a Finished message that contains a MAC over the entire handshake transcript, proving they derived the same keys.

How the keys are derived

  • Both sides compute a shared secret using the Diffie-Hellman (or elliptic-curve) exchange embedded in the ClientHello/ServerHello.
  • They then run a key-derivation function (HKDF) over the shared secret and the two nonces to produce symmetric keys for encryption (AEAD) and MAC.

After step 4, the TLS tunnel is ready. All subsequent HTTP requests travel inside the encrypted channel, and the application layer never sees the raw bytes.

Where TLS shows up in classic interview questions

Design QuestionWhere TLS appearsWhat you should say
Global load-balanced web serviceBetween client and edge load balancer (e.g., AWS ELB)"We terminate TLS at the ELB, which offloads the expensive handshake from the app servers."
Microservice API gatewayBetween gateway and internal services (service-to-service TLS)"Each microservice presents a certificate; the gateway validates it, preventing rogue services from hijacking traffic."
Content Delivery Network (CDN) edge nodeBetween CDN edge and origin server"Origin Pull uses TLS to protect the back-haul; the edge node caches the response after the handshake completes."

In each case, the handshake occurs exactly once per TCP connection, then the encrypted channel can be reused for many HTTP requests (keep-alive) or closed after a short idle period.

Trade-offs and the alternative interview question

Latency

TLS adds round-trip time (RTT) to the first request. In TLS 1.3 the handshake completes in one round trip (ClientHello out; ServerHello, certificate and Finished back), on top of the round trip TCP already needs to open the connection. For a user on a 100 ms network, that is about 100 ms extra latency.

CPU cost

The cryptographic operations (ECDHE key exchange, AEAD encryption) consume CPU cycles. On a typical x86 server, a full handshake may cost a few hundred microseconds; at massive scale that adds up, so teams lean on session resumption, long-lived connections and a dedicated TLS termination tier to keep CPU usage in check.

Session resumption

To mitigate latency, servers support session tickets or TLS 1.3 0-RTT. The client presents a previously issued ticket, and the server can skip the expensive key exchange. The trade-off is a small window where replay attacks are possible, so you must limit what can be done in 0-RTT.

Alternative the interviewer may ask about

Often the next question is: "What if we cannot afford the TLS latency?" The expected alternative is VPN or IPsec for site-to-site encryption, or plain HTTP inside a trusted private network. You should contrast the scope: VPN encrypts the whole IP packet and is cheaper per-connection but does not provide per-service authentication.

A 30-second spoken version

"TLS is the handshake that creates a secure channel before any data is sent. The client says what cryptography it supports, the server picks a suite, sends its certificate, and both sides derive shared keys using Diffie-Hellman. After one round-trip the channel is encrypted, protecting confidentiality and preventing man-in-the-middle attacks. In a design you usually terminate TLS at the load balancer or API gateway, and you may use session tickets to reduce latency. The downside is extra RTT and CPU cost, so you might consider 0-RTT or hardware offload if traffic is huge."

Common mistakes candidates make

  • Skipping the why – Mentioning TLS without explaining the threat model (e.g., eavesdropping) makes it sound like a checkbox.
  • Mixing up layers – Describing TLS as a routing protocol or as part of the database layer confuses the network stack.
  • Omitting the handshake steps – Saying "TLS encrypts traffic" without the ClientHello/ServerHello exchange loses points.
  • Ignoring session resumption – Interviewers expect you to talk about tickets or 0-RTT when scaling to millions of connections.
  • Assuming TLS is free – Forgetting to account for CPU and latency can lead to an unrealistic capacity estimate.

How to practice this

  1. Draw the request path – Sketch a client, load balancer, and backend service. Mark where the TLS handshake occurs and label the messages.
  2. Explain the flow out loud – Use the 30-second pitch and then expand each step, noting where you would add session tickets.
  3. Run a mock interview – Use System Design AI to practice drawing the answer on a canvas and get feedback on the completeness of your TLS description.

Questions people ask

Do I need to mention TLS 1.2 vs TLS 1.3?

Mentioning that TLS 1.3 reduces the handshake to one RTT shows depth, but you can keep the explanation at a high level unless the interviewer asks for version differences.

Should I talk about certificate authorities?

Briefly note that the server presents a certificate signed by a trusted CA; the client validates the chain to ensure authenticity.

How does TLS interact with HTTP/2?

HTTP/2 is usually deployed over TLS; the handshake happens first, then multiplexed streams share the same encrypted connection.

Is it ever acceptable to skip TLS in a design?

Only when the entire system runs inside a trusted private network and latency or CPU constraints are extreme; you must justify the risk reduction.