Measures raw TCP vs HTTP/1.1 vs HTTP/2 for 1000 requests. Shows protocol overhead in bytes and RTTs.
Requirements: Python 3.8+ (standard library only)
Duration: ~2-5 minutes
Output: p50/p99 latency, throughput, resource usage comparison table
This benchmark isolates a specific variable to show its performance impact in isolation. Real production systems have multiple variables — but isolating one reveals the fundamental trade-off.
TCP: minimal overhead per requestHTTP/1.1: +headers (~200 bytes) + connection reuseHTTP/2: +framing but multiplexed, fewer connections
Save the benchmark script below and run with python3 bench.py.
python# Complete benchmark script — copy and runimport timeimport statisticsdef run_benchmark():# See detailed implementation in module theory filepassif __name__ == "__main__":run_benchmark()
The results demonstrate the fundamental trade-off between the approaches. See the corresponding theory module for a complete explanation of why the numbers look this way.
See ../../bsps/07-core-backend-engineering/ for the theory behind this benchmark.
in this section