TLS Connection Overhead Calculator

TLS Connection Overhead Calculator

animation
http
app-protocols
Try Open the TLS connection overhead Calculator panel, change one input, then press Calculate connection overhead.
Observe After pressing Calculate connection overhead, watch how the TLS connection overhead Calculator results update.
Explain Explain why the TLS connection overhead Calculator results changed after you press Calculate connection overhead.

Technical boundaries. TCP, TLS, and HTTP times use fixed RTT multipliers. The formula treats pool size as requests per connection and amortizes setup cost over those requests.

Calculate the latency impact of TLS handshakes with and without connection pooling:

viewof rtt = Inputs.range([10, 500], {
  value: 100,
  step: 10,
  label: "Network RTT (milliseconds)"
})

viewof requestsPerMinute = Inputs.range([1, 300], {
  value: 60,
  step: 1,
  label: "Requests per minute"
})

viewof keepAliveConnections = Inputs.range([1, 100], {
  value: 10,
  step: 1,
  label: "Keep-alive pool size"
})
{
  const tcpHandshake = rtt * 1.5;
  const tlsHandshake = rtt * 2.0;
  const httpRequest = rtt * 1.0;
  const totalNoPooling = tcpHandshake + tlsHandshake + httpRequest;
  const totalWithPooling = httpRequest; // Only pay connection cost once

  const dailyRequests = requestsPerMinute * 60 * 24;
  const connectionsPerDay = Math.ceil(dailyRequests / keepAliveConnections);
  const amortizedOverhead = (tcpHandshake + tlsHandshake) / keepAliveConnections;
  const avgLatencyPooling = httpRequest + amortizedOverhead;

  const reduction = ((totalNoPooling - avgLatencyPooling) / totalNoPooling * 100).toFixed(1);

  return html`
    <div style="font-family: Arial, sans-serif; padding: 15px; background: #f8f9fa; border-radius: 8px; border-left: 4px solid #2C3E50;">
      <p style="margin-top: 0; margin-bottom: 0.8em; color: #2C3E50; font-weight: 700; font-size: 1.1em;">Request Latency Impact</p>
      <div style="display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin: 20px 0;">
        <div style="background: white; padding: 15px; border-radius: 6px; border-top: 3px solid #E67E22;">
          <div style="font-size: 0.9em; color: #7F8C8D; margin-bottom: 5px;">No Connection Pooling</div>
          <div style="font-size: 2em; font-weight: bold; color: #E67E22;">${totalNoPooling.toFixed(0)}</div>
          <div style="font-size: 0.9em; color: #7F8C8D;">ms per request</div>
          <div style="font-size: 0.8em; color: #7F8C8D; margin-top: 8px;">
            TCP: ${tcpHandshake.toFixed(0)}ms<br/>
            TLS: ${tlsHandshake.toFixed(0)}ms<br/>
            HTTP: ${httpRequest.toFixed(0)}ms
          </div>
        </div>
        <div style="background: white; padding: 15px; border-radius: 6px; border-top: 3px solid #16A085;">
          <div style="font-size: 0.9em; color: #7F8C8D; margin-bottom: 5px;">With Connection Pooling</div>
          <div style="font-size: 2em; font-weight: bold; color: #16A085;">${avgLatencyPooling.toFixed(0)}</div>
          <div style="font-size: 0.9em; color: #7F8C8D;">ms per request</div>
          <div style="font-size: 0.8em; color: #7F8C8D; margin-top: 8px;">
            Amortized setup: ${amortizedOverhead.toFixed(0)}ms<br/>
            HTTP: ${httpRequest.toFixed(0)}ms<br/>
            <strong>${reduction}% faster</strong>
          </div>
        </div>
      </div>
      <div style="background: white; padding: 15px; border-radius: 6px;">
        <strong style="color: #2C3E50;">Daily Connection Efficiency</strong><br/>
        <span style="color: #7F8C8D; font-size: 0.9em;">
          ${dailyRequests.toLocaleString()} requests/day → ${connectionsPerDay.toLocaleString()} connections needed<br/>
          Each connection handles ~${Math.floor(dailyRequests / connectionsPerDay)} requests<br/>
          Setup cost amortized over ${keepAliveConnections} requests per connection
        </span>
      </div>
    </div>
  `;
}

Back to the chapter