Backend Development 13 min read

Understanding HTTP/2: Overview, Principles, Implementation, and Performance Optimization

This article provides a comprehensive overview of the HTTP/2 protocol, explaining its binary framing, multiplexing, header compression, request prioritization, and server push features, and offers step‑by‑step guidance for upgrading Nginx to support HTTP/2 along with detection methods.

Sohu Tech Products
Sohu Tech Products
Sohu Tech Products
Understanding HTTP/2: Overview, Principles, Implementation, and Performance Optimization

HTTP/2 is a secure and efficient next‑generation HTTP transport protocol built on HTTPS and binary framing; as of August 2018, about 27.9% of websites support it.

It retains the semantics of HTTP/1.x (methods, status codes, etc.) while improving performance, using a single connection and incorporating lessons from SPDY.

Binary framing divides all transmitted data into frames, each containing a type, length, flags, stream identifier, and payload; messages are composed of one or more frames, and streams are virtual channels with odd IDs for client‑initiated streams and even IDs for server‑initiated streams.

Multiplexing allows many concurrent request‑response messages over a single connection; frames can be interleaved, reordered, and prioritized, eliminating the per‑domain connection limits of HTTP/1.1.

Header compression is handled by the HPACK algorithm, which uses a static and a dynamic table to replace header fields with indexes and applies Huffman coding to further reduce size.

Request priorities assign a 31‑bit priority value to each stream (0 = highest); servers allocate CPU, memory, and bandwidth based on these values, with typical ordering: HTML > CSS > JavaScript > images.

Server push enables the server to send multiple responses (e.g., assets) without explicit client requests, improving latency and allowing shared caching across pages.

While HTTP/2 brings performance gains, it also introduces new bottlenecks because all traffic shares a single TCP connection, making TCP head‑of‑line blocking a potential issue that requires careful tuning.

To upgrade Nginx to HTTP/2 you need Nginx ≥ 1.9.5 compiled with --with-http_ssl_module and --with-http_v2_module . Verify with nginx -V , configure with ./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_v2_module , then compile and install using make and make install . Add http2 to the listen directive on port 443 in the config and restart with nginx restart .

Detection methods include checking the Protocol column (showing “h2”) in Chrome DevTools, using SSL Labs’ SSL test, or installing the “HTTP/2 and SPDY indicator” browser extension.

PerformanceNginxProtocolHTTP/2MultiplexingBinary Framing
Sohu Tech Products
Written by

Sohu Tech Products

A knowledge-sharing platform for Sohu's technology products. As a leading Chinese internet brand with media, video, search, and gaming services and over 700 million users, Sohu continuously drives tech innovation and practice. We’ll share practical insights and tech news here.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.