HeadlinesBriefing favicon HeadlinesBriefing.com

Why Google's HTTP/2 Codec Slows Down Envoy

Hacker News •
×

An Envoy version bump recently cost a customer 20% of their HTTP/2 throughput. The investigation revealed that switching the default HTTP/2 codec from the original nghttp2 to Google's oghttp2 caused significant latency regressions. Benchmarks across multiple microarchitectures confirmed that nghttp2 outperforms oghttp2 by 15–25% on header-heavy traffic.

The performance bottleneck lies in header decompression. Every HTTP/2 request requires decoding and re-encoding headers using the HPACK compression scheme. This process relies heavily on Huffman coding to handle literal strings. While Huffman coding is provably optimal, the decoding process is computationally expensive due to the bit-level traversal required for each character.

Research shows that nghttp2 maintains its edge by using a precomputed finite-state machine for decoding. This allows it to avoid expensive branching and bit-buffering by using table lookups. Consequently, Envoy v1.37.0 eventually reverted to the default nghttp2 codec to restore performance.