viewof numSensors = Inputs.range([1, 200], {
value: 50,
step: 1,
label: "Number of sensors"
})
viewof rttMs = Inputs.range([10, 500], {
value: 100,
step: 10,
label: "Network RTT (ms)"
})
viewof headerSize = Inputs.range([50, 500], {
value: 350,
step: 10,
label: "HTTP/1.1 header size (bytes)"
})
viewof payloadSize = Inputs.range([50, 2000], {
value: 200,
step: 50,
label: "Payload size per request (bytes)"
})
// Calculations
http11Time = numSensors * (3.5 * rttMs) // 3.5 RTT per request (TCP + TLS)
http2Time = (2 * rttMs) + (rttMs * 0.5) // Initial handshake + 0.5 RTT per request
speedup = http11Time / http2Time
http11Bandwidth = numSensors * (180 + 3200 + headerSize + payloadSize + 250 + 240) // TCP + TLS + headers + payload + response
http2Bandwidth = 3380 + numSensors * (45 + payloadSize + 20) // Initial handshake + compressed headers
bandwidthSavings = ((http11Bandwidth - http2Bandwidth) / http11Bandwidth * 100)
html`<div style="background: #f8f9fa; padding: 20px; border-radius: 8px; border-left: 4px solid #16A085; margin-top: 15px;">
<p style="color: #2C3E50; margin-top: 0; font-weight: 700;">Results</p>
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 15px;">
<div style="background: white; padding: 15px; border-radius: 6px; border: 1px solid #dee2e6;">
<div style="color: #7F8C8D; font-size: 0.85em; text-transform: uppercase; margin-bottom: 5px;">HTTP/1.1 Time</div>
<div style="font-size: 1.5em; font-weight: bold; color: #E67E22;">${(http11Time / 1000).toFixed(2)}s</div>
</div>
<div style="background: white; padding: 15px; border-radius: 6px; border: 1px solid #dee2e6;">
<div style="color: #7F8C8D; font-size: 0.85em; text-transform: uppercase; margin-bottom: 5px;">HTTP/2 Time</div>
<div style="font-size: 1.5em; font-weight: bold; color: #16A085;">${(http2Time / 1000).toFixed(2)}s</div>
</div>
<div style="background: white; padding: 15px; border-radius: 6px; border: 1px solid #dee2e6;">
<div style="color: #7F8C8D; font-size: 0.85em; text-transform: uppercase; margin-bottom: 5px;">Speedup</div>
<div style="font-size: 1.5em; font-weight: bold; color: #2C3E50;">${speedup.toFixed(1)}×</div>
</div>
<div style="background: white; padding: 15px; border-radius: 6px; border: 1px solid #dee2e6;">
<div style="color: #7F8C8D; font-size: 0.85em; text-transform: uppercase; margin-bottom: 5px;">Bandwidth Savings</div>
<div style="font-size: 1.5em; font-weight: bold; color: #16A085;">${bandwidthSavings.toFixed(1)}%</div>
</div>
</div>
<div style="margin-top: 20px; padding: 15px; background: white; border-radius: 6px; border: 1px solid #dee2e6;">
<div style="color: #7F8C8D; font-size: 0.85em; margin-bottom: 10px;">DATA TRANSFER COMPARISON</div>
<div style="display: flex; gap: 10px; align-items: center;">
<div style="flex: 1;">
<div style="font-size: 0.85em; color: #7F8C8D; margin-bottom: 3px;">HTTP/1.1</div>
<div style="background: #E67E22; height: 20px; border-radius: 4px; width: 100%;"></div>
<div style="font-size: 0.85em; color: #7F8C8D; margin-top: 3px;">${(http11Bandwidth / 1024).toFixed(1)} KB</div>
</div>
<div style="flex: 1;">
<div style="font-size: 0.85em; color: #7F8C8D; margin-bottom: 3px;">HTTP/2</div>
<div style="background: #16A085; height: 20px; border-radius: 4px; width: ${(http2Bandwidth / http11Bandwidth * 100).toFixed(0)}%;"></div>
<div style="font-size: 0.85em; color: #7F8C8D; margin-top: 3px;">${(http2Bandwidth / 1024).toFixed(1)} KB</div>
</div>
</div>
</div>
<div style="margin-top: 15px; padding: 12px; background: #e8f5f2; border-radius: 6px; font-size: 0.9em; color: #2C3E50;">
<strong>Insight:</strong> With ${numSensors} sensors and ${rttMs}ms RTT, HTTP/2 multiplexing delivers <strong>${speedup.toFixed(1)}× faster</strong> uploads and saves <strong>${bandwidthSavings.toFixed(1)}%</strong> bandwidth through HPACK header compression.
</div>
</div>`Interactive Calculator: HTTP/2 Multiplexing Savings
Interactive Calculator: HTTP/2 Multiplexing Savings
animation
http
protocols
Try Increase Number of sensors while keeping network RTT fixed. Then press Calculate multiplexing savings.
Observe After pressing Calculate multiplexing savings, watch speedup and bandwidth savings as Number of sensors changes.
Explain Explain why Number of sensors changes HTTP/1.1 time but leaves HTTP/2 time fixed.
Technical boundaries. HTTP/1.1 time uses 3.5 RTT per sensor; HTTP/2 time stays at 2.5 RTT. Bandwidth uses fixed handshake and compressed header byte assumptions.