HTTP/2 and HTTP/3 transform HTTP from a heavyweight protocol into a viable IoT option for gateways and mobile scenarios. HTTP/2’s multiplexing reduces per-request handshake overhead and can make gateway connections 50x faster, while HTTP/3’s QUIC transport over UDP eliminates TCP head-of-line blocking and provides 0-RTT connection resumption that reduces cellular IoT power consumption by 30-50%. These are not replacements for MQTT or CoAP on constrained devices – they require 32KB+ RAM – but they efficiently leverage existing HTTP infrastructure where resources allow.
7.1 Learning Objectives
By the end of this chapter, you will be able to:
Explain HTTP/2 Multiplexing: Describe how binary framing, stream multiplexing, and HPACK header compression reduce IoT gateway overhead by up to 76%
Evaluate HTTP/3 vs HTTP/2: Compare QUIC transport benefits against TCP-based HTTP/2 for mobile and cellular IoT deployments, justifying the choice based on network conditions
Select the Appropriate Protocol: Distinguish between HTTP/1.1, HTTP/2, and HTTP/3 based on device RAM constraints, network stability, and firewall policies
Configure Modern HTTP: Implement HTTP/2 and HTTP/3 settings for IoT gateways and cloud backends, including keep-alive tuning and QUIC server configuration
Calculate Protocol Overhead: Assess bandwidth and latency costs for each HTTP version and apply the correct formula to estimate cellular radio active time and battery impact
Diagnose Head-of-Line Blocking: Analyze why HTTP/2 over TCP suffers transport-layer HOL blocking under packet loss, and demonstrate how HTTP/3 QUIC streams solve this
7.2 Prerequisites
Before diving into this chapter, you should be familiar with:
HTTP/2 and HTTP/3 transform HTTP from a heavyweight protocol into a viable IoT option for gateway and mobile scenarios. The key insight is that modern HTTP isn’t about replacing MQTT or CoAP for constrained devices - it’s about leveraging existing HTTP infrastructure efficiently when you have sufficient resources (32KB+ RAM). HTTP/2’s multiplexing can make gateway scenarios 50x faster, while HTTP/3’s QUIC transport with 0-RTT resumption can reduce cellular IoT power consumption by 30-50%.
Cross-Hub Connections
Explore Related Learning Resources:
Video Library: Watch tutorials on HTTP/2 and QUIC protocol implementations
Meet the Sensor Squad! Sammy the Temperature Sensor needs to send LOTS of messages to the Cloud Castle, but the old road is SO SLOW!
The Problem: Sammy and 49 other sensors all want to send their readings to the Cloud Castle using HTTP/1.1. But the old road only has ONE lane!
“We have to wait in line FOREVER!” complains Sammy. “By the time my message arrives, the temperature has already changed!”
Lila the Light Sensor has an idea: “What if we could all travel on the SAME road at the SAME time? That’s what HTTP/2 does - it’s like a multi-lane highway!”
Bella the Button is amazed: “Wow, 50 times faster! But what about when the road has potholes?”
Max explains HTTP/3: “HTTP/3 uses magic flying cars (QUIC)! If one car hits a pothole, the others just fly over it. Nobody has to wait!”
Sammy’s Rules for Choosing Roads:
Situation
Best Road
Why
Tiny sensors with small batteries
Use the bicycle path (CoAP/MQTT)
Less energy needed!
Gateway sending many messages
Use the multi-lane highway (HTTP/2)
All messages travel together!
Car tracker on bumpy cellular
Use the flying cars (HTTP/3)
Doesn’t get stuck in potholes!
The Happy Ending: Sammy and all 50 sensors now use HTTP/2 to send their readings through the gateway. What used to take 10 seconds now takes only 200 milliseconds! And when Sammy’s friend Carla the Car Tracker travels on bumpy cellular networks, she uses HTTP/3’s flying cars to never get stuck.
The Lesson: Modern HTTP is like upgrading from a single-lane country road to a superhighway - perfect for when you have lots of data to move quickly!
Key Concepts
Core Concept: Fundamental principle underlying HTTP/2 and HTTP/3 for IoT — understanding this enables all downstream design decisions
Key Metric: Primary quantitative measure for evaluating HTTP/2 and HTTP/3 for IoT performance in real deployments
Trade-off: Central tension in HTTP/2 and HTTP/3 for IoT design — optimizing one parameter typically degrades another
Protocol/Algorithm: Standard approach or algorithm most commonly used in HTTP/2 and HTTP/3 for IoT implementations
Deployment Consideration: Practical factor that must be addressed when deploying HTTP/2 and HTTP/3 for IoT in production
Common Pattern: Recurring design pattern in HTTP/2 and HTTP/3 for IoT that solves the most frequent implementation challenges
Performance Benchmark: Reference values for HTTP/2 and HTTP/3 for IoT performance metrics that indicate healthy vs. problematic operation
7.3 Introduction: Beyond HTTP/1.1
While HTTP/1.1 is often dismissed as too heavyweight for IoT, the newer HTTP/2 and HTTP/3 protocols offer significant improvements that make HTTP more viable for certain IoT applications.
HTTP Protocol Stack Comparison: HTTP/1.1 vs HTTP/2 vs HTTP/3
Figure 7.1: HTTP Protocol Stack Comparison: HTTP/1.1 vs HTTP/2 vs HTTP/3
For Beginners: Why Modern HTTP Matters
Think of HTTP/1.1 like a single-lane road where cars (requests) must wait for each other. HTTP/2 is like a multi-lane highway where many cars travel simultaneously. HTTP/3 goes further - it’s like having flying cars that don’t get stuck in traffic jams caused by road damage (packet loss).
For IoT devices that need to send lots of small messages or work over unreliable cellular networks, these improvements can mean: - Faster data delivery - Less battery drain - More reliable connections
7.4 HTTP/2: Multiplexing and Header Compression
HTTP/2 addresses many HTTP/1.1 limitations with binary framing, multiplexed streams, and header compression.
7.4.1 Key Improvements Over HTTP/1.1
Feature
HTTP/1.1
HTTP/2
IoT Benefit
Connections
Multiple TCP connections needed
Single connection, multiplexed streams
Reduced handshake overhead
Headers
Repeated in full each request
HPACK compression (90%+ reduction)
Smaller packet sizes
Server Push
Not supported
Server can proactively send resources
Efficient firmware distribution
Binary Protocol
Text-based (verbose)
Binary framing
Faster parsing on MCUs
Stream Priority
None
Priority hints for streams
Critical data first
HTTP/1.1 Sequential Requests vs HTTP/2 Multiplexed Streams
Figure 7.2: HTTP/1.1 Sequential Requests vs HTTP/2 Multiplexed Streams
7.4.2 Header Compression with HPACK
One of HTTP/2’s most impactful features for IoT is HPACK header compression:
HTTP/1.1 headers (repeated every request):
Content-Type: application/json
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
User-Agent: IoT-Sensor/1.0
Accept: application/json
Host: api.example.com
(~350 bytes per request)
HTTP/2 with HPACK:
First request: ~350 bytes (headers indexed)
Subsequent requests: ~15-30 bytes (index references only)
Savings: 90%+ for repeated headers
Show code
InlineKnowledgeCheck({containerId:"kc-http2-hpack-inline",question:"After the first HTTP/2 request sends full headers (~350 bytes), what does HPACK send for the same headers on subsequent requests to the same server?",options: ["~15-30 bytes of index references into the shared header table","The same ~350 bytes, because headers must be re-validated each time","Zero bytes, because the server caches all headers permanently","~175 bytes, because HPACK compresses headers by exactly 50%" ],correctIndex:0,explanation:"HPACK builds a shared header table indexed between client and server. After the first request populates the table, subsequent requests with the same headers (Host, Authorization, Content-Type, etc.) send only small integer index references — typically 15-30 bytes — instead of retransmitting the full header strings. This 90%+ reduction is especially valuable for IoT devices that repeat the same headers on every reading upload.",difficulty:"intermediate"})
7.4.3 Multiplexing Benefits for IoT Gateways
Scenario: Gateway aggregating 50 sensors, sending to cloud
HTTP/1.1 approach:
- 50 sequential requests OR 6-8 parallel connections
- Each connection: TCP handshake (1.5 RTT) + TLS (2 RTT)
- Total overhead: 50 x 200ms = 10 seconds
HTTP/2 approach:
- Single TCP+TLS connection (1 RTT handshake, amortized)
- 50 multiplexed streams in parallel
- Total time: ~200ms (1 RTT + minimal framing)
- 50x faster for gateway scenarios
HTTP/2 Gateway Scenario: Parallel Sensor Data Upload
Figure 7.3: HTTP/2 Gateway Scenario: Parallel Sensor Data Upload
7.5 HTTP/3: QUIC Transport for Unreliable Networks
HTTP/3 replaces TCP with QUIC (UDP-based), offering advantages for IoT deployments with unstable connectivity.
7.5.1 Key Features for IoT
Feature
HTTP/2 (TCP)
HTTP/3 (QUIC)
IoT Use Case
Connection establishment
3-way handshake + TLS
0-RTT or 1-RTT
Mobile/cellular IoT
Head-of-line blocking
Stream blocked by packet loss
Independent streams
Lossy wireless links
Connection migration
Breaks on IP change
Survives network switch
Vehicle telematics
Congestion control
Per-connection
Per-stream
Mixed priority data
HTTP/3 QUIC Features Mapped to IoT Benefits
Figure 7.4: HTTP/3 QUIC Features Mapped to IoT Benefits
7.5.2 0-RTT Connection Resumption
The following comparison shows the dramatic difference in connection establishment time:
Scenario: Cellular IoT device waking from sleep
TCP + TLS 1.3:
1. TCP SYN (1 RTT)
2. TCP SYN-ACK + TLS ClientHello
3. TLS ServerHello + Application data (1 RTT)
Total: 2 RTT before sending data (~200-400ms on cellular)
QUIC (HTTP/3) with 0-RTT:
1. ClientHello + Encrypted data (0 RTT!)
2. Server response
Total: 0 RTT for resumed connections
Power savings: 30-50% reduction in radio active time
Connection Latency Comparison: TCP+TLS vs QUIC
Figure 7.5: Connection Latency Comparison: TCP+TLS vs QUIC
Latency Impact on Cellular IoT
On a typical LTE network with 100ms RTT:
HTTP/1.1 + TLS 1.2: ~350-400ms before first data (radio active for 400ms)
HTTP/2 + TLS 1.3: ~250-300ms before first data (25% improvement)
HTTP/3 + QUIC 0-RTT: ~100ms for resumed connections (70% improvement)
For a device waking 96 times per day (every 15 minutes), this translates to: - HTTP/1.1: 33.6 seconds of radio time/day (96 × 3.5 RTTs × 100 ms) - HTTP/3: 9.6 seconds of radio time/day (96 × 1.0 RTT × 100 ms) - Battery savings: ~71% reduction in connection overhead
Putting Numbers to It
Connection latency directly translates to radio active time. For \(n\) wake cycles per day with RTT \(t\) milliseconds:
\[T_{\text{active}} = n \cdot k \cdot t\]
where \(k\) is the RTT multiplier: \(k_{\text{HTTP/1.1}} = 3.5\), \(k_{\text{HTTP/2}} = 2.5\), \(k_{\text{HTTP/3,0-RTT}} = 1\).
The following decision flowchart helps you select the appropriate HTTP version (or alternative protocol) based on your IoT device constraints and network environment.
HTTP Protocol Selection Decision Tree for IoT Applications
Figure 7.8: HTTP Protocol Selection Decision Tree for IoT Applications
7.6.1 When to Use HTTP/2
Choose HTTP/2 when:
IoT gateway aggregating many device messages to cloud
Existing HTTP/REST infrastructure must be preserved
Devices have sufficient memory (32KB+ RAM for TLS+HTTP/2 stack)
Connection reuse is possible (persistent connection to backend)
Example: Smart building gateway sending HVAC data to cloud API
7.6.2 When to Use HTTP/3
Choose HTTP/3 when:
Cellular IoT with frequent sleep/wake cycles
Mobile assets changing networks (vehicles, drones, wearables)
7.7.4 Real-World Case Study: Fleet Tracking System
The following diagram illustrates a real-world fleet tracking architecture using HTTP/3 for mobile assets:
Real-World Case Study: Fleet Tracking with HTTP/3
Figure 7.9: Real-World Case Study: Fleet Tracking with HTTP/3
Key Benefits Demonstrated:
Connection Migration: Trucks seamlessly switch between cell towers without dropping connection
0-RTT Resumption: Vehicles waking from sleep send GPS data immediately
Independent Streams: Real-time telemetry and firmware updates don’t interfere with each other
7.7.5 Python HTTP/2 Gateway Example
# Python example: HTTP/2 with connection reuse for gatewayimport httpximport asyncio# Create reusable HTTP/2 clientclient = httpx.Client( http2=True, timeout=30.0, limits=httpx.Limits( max_keepalive_connections=5, max_connections=10, keepalive_expiry=3600# 1 hour for IoT ))# Batch sensor readings efficientlyasyncdef upload_sensor_batch(readings: list[dict]):"""Upload multiple sensor readings in parallel over single HTTP/2 connection"""asyncwith httpx.AsyncClient(http2=True) as client: tasks = [ client.post(f"/api/v1/sensors/{r['device_id']}/data", json=r)for r in readings ] responses =await asyncio.gather(*tasks)# All 50 requests share single connection, multiplexedreturn responses
7.8 Protocol Comparison Summary
Protocol
Best For
Overhead
Latency
Reliability
CoAP
Constrained devices, 6LoWPAN
Very Low
Lowest
Application-managed
MQTT
Event streams, pub-sub
Low
Low
QoS 0/1/2
HTTP/1.1
Simple prototyping, debugging
High
Medium
TCP
HTTP/2
Gateways, cloud APIs, bulk uploads
Medium
Medium
TCP + multiplexing
HTTP/3
Mobile IoT, unreliable networks
Medium
Lowest
QUIC streams
7.8.1 Protocol Positioning in the IoT Landscape
The following diagram shows how HTTP/2 and HTTP/3 fit into the broader IoT protocol ecosystem:
HTTP/2 and HTTP/3 in the IoT Protocol Landscape
Figure 7.10: HTTP/2 and HTTP/3 in the IoT Protocol Landscape
The following timeline shows how HTTP has evolved to address IoT requirements:
Evolution of HTTP Protocols and IoT Suitability
Figure 7.11: Evolution of HTTP Protocols and IoT Suitability
Protocol Positioning by Overhead and Feature Richness
Figure 7.12: Protocol Positioning by Overhead and Feature Richness
7.9 Real-World Tradeoffs
When selecting between HTTP versions in production IoT deployments, consider these practical tradeoffs:
HTTP/2 vs HTTP/3 Tradeoff Analysis for IoT
Figure 7.13: HTTP/2 vs HTTP/3 Tradeoff Analysis for IoT
7.9.1 Quantitative Comparison
Metric
HTTP/2
HTTP/3
Winner For
Connection Setup
2-3 RTT (TCP+TLS)
0-1 RTT (QUIC)
HTTP/3: Mobile IoT
Memory Footprint
~32KB
~64KB
HTTP/2: Constrained gateways
Packet Loss Impact
All streams blocked
Independent streams
HTTP/3: Lossy networks
Network Handoff
Connection drops
Survives IP change
HTTP/3: Vehicle tracking
Firewall Traversal
~99% success
~85% success
HTTP/2: Enterprise
Library Maturity
Excellent
Good (improving)
HTTP/2: Production systems
Debug Tooling
Mature (Chrome, curl)
Developing
HTTP/2: Development phase
Deployment Strategy
Start with HTTP/2 for initial deployments - it offers significant improvements over HTTP/1.1 with excellent tooling and support. Upgrade to HTTP/3 when you have proven the value proposition and your mobile/cellular use cases justify the added complexity.
7.10 Common Pitfalls
Avoid These Mistakes
1. Assuming HTTP/3 is Always Better
HTTP/3’s QUIC transport offers significant advantages for mobile and lossy networks, but it’s not universally better:
UDP may be blocked by enterprise firewalls
HTTP/3 requires more RAM (~64KB vs ~32KB for HTTP/2)
Library support is still maturing on embedded platforms
For stable networks, HTTP/2 provides similar benefits with wider support
2. Ignoring Memory Constraints
Modern HTTP protocols have significant memory overhead:
HTTP/2 HPACK tables need ~16-32KB RAM
HTTP/3 QUIC state needs ~64KB RAM
Don’t assume gateway-level protocols work on constrained sensors
Always verify RAM budget before selecting protocol
3. Opening Multiple HTTP/2 Connections
The whole point of HTTP/2 multiplexing is to use a SINGLE connection:
# WRONG: Creating new connection per requestfor sensor in sensors: response = httpx.post(url, json=sensor.data) # New connection each time!# RIGHT: Reusing single multiplexed connectionasyncwith httpx.AsyncClient(http2=True) as client: tasks = [client.post(url, json=s.data) for s in sensors] responses =await asyncio.gather(*tasks) # All share one connection
4. Not Configuring Keep-Alive for IoT
Default HTTP timeouts are too short for IoT:
# nginx - extend for IoT workloadskeepalive_timeout 3600s; # 1 hour, not default 75shttp2_idle_timeout 600s; # 10 minutes idle before close
5. Forgetting 0-RTT Replay Attacks
HTTP/3’s 0-RTT is vulnerable to replay attacks. For idempotent operations (GET, sensor readings) this is fine, but for non-idempotent operations (commands, actuator triggers), use 1-RTT or implement replay protection.
7.11 Knowledge Check
Test your understanding of HTTP/2 and HTTP/3 for IoT applications:
Show code
InlineKnowledgeCheck({containerId:"kc-http-modern-1",question:"A smart building gateway needs to send data from 50 HVAC sensors to a cloud API that only supports HTTP. Which protocol version would provide the BEST performance improvement over HTTP/1.1?",options: [ {text:"HTTP/2 - multiplexing enables all 50 requests over a single connection",feedback:"Correct! HTTP/2 multiplexing lets all 50 sensor streams share one TCP connection, eliminating per-request TCP+TLS handshake overhead and delivering up to 50x speedup for this gateway scenario."}, {text:"HTTP/3 - QUIC transport is always faster than TCP",feedback:"Not quite. HTTP/3 is NOT always faster than TCP — on stable LAN or enterprise Wi-Fi networks HTTP/2 performs comparably with far better library support. HTTP/3 shines on mobile/cellular networks; the claim 'always faster' is the key misconception here."}, {text:"HTTP/1.1 with connection pooling - simpler and equally effective",feedback:"Incorrect. HTTP/1.1 connection pooling only allows 6-8 parallel TCP connections, each with its own handshake overhead. For 50 sensors, this means multiple waves of connections. HTTP/2 sends all 50 streams over a SINGLE connection with one amortised handshake — far more efficient."}, {text:"WebSocket - better suited for multiple data streams",feedback:"Incorrect. WebSocket is designed for persistent bidirectional push channels, not for multiplexing many independent short-lived sensor uploads. HTTP/2's multiplexed streams are the right fit for this upload scenario where the cloud API is HTTP-based."} ],correctIndex:0,explanation:"HTTP/2 is ideal for gateway scenarios because multiplexing allows all 50 sensor requests to travel simultaneously over a single TCP connection. This eliminates the TCP handshake overhead per request (which HTTP/1.1 requires) and can be up to 50x faster. HTTP/3 would also work but HTTP/2 is more widely supported and sufficient for stable network connections like a building's infrastructure.",difficulty:"intermediate"})
Show code
InlineKnowledgeCheck({containerId:"kc-http-modern-2",question:"A fleet tracking system uses LTE cellular modems that frequently switch between cell towers. Which HTTP feature is MOST important for maintaining reliable connections?",options: [ {text:"HTTP/2 header compression (HPACK)",feedback:"Incorrect. HPACK reduces header bytes by 90%, which saves bandwidth, but it does NOT help when the underlying TCP connection is broken by an IP address change. When a truck switches cell towers and gets a new IP, the TCP connection terminates regardless of HPACK compression."}, {text:"HTTP/3 connection migration via Connection ID",feedback:"Correct! QUIC uses a Connection ID independent of IP:port, so the connection survives a cell tower handoff even though the device's IP address changes. This is the defining advantage for fleet tracking over LTE."}, {text:"HTTP/2 server push for firmware updates",feedback:"Incorrect. Server push lets the server proactively send resources before the client requests them — useful for web assets or OTA initiation, but it offers no help when the connection is dropped due to IP address change during a cell handoff. The vehicle still loses connectivity."}, {text:"HTTP/1.1 keep-alive connections",feedback:"Incorrect. HTTP/1.1 keep-alive reuses an existing TCP connection for multiple sequential requests, reducing overhead on stable connections. However, TCP connections are identified by the IP:port 4-tuple, so any IP address change (e.g., switching cell towers) immediately breaks the connection and forces a full reconnection."} ],correctIndex:1,explanation:"HTTP/3's connection migration is critical for mobile IoT. Traditional TCP connections break when the device's IP address changes (switching cell towers), requiring a full reconnection. HTTP/3 uses QUIC's Connection ID instead of IP:port tuples, allowing connections to survive network handoffs seamlessly. This is essential for vehicle telematics and mobile asset tracking.",difficulty:"intermediate"})
Show code
InlineKnowledgeCheck({containerId:"kc-http-modern-3",question:"A cellular IoT device wakes from deep sleep every 15 minutes to send a sensor reading. Using HTTP/3 with 0-RTT resumption instead of HTTP/2, approximately how much power savings can be expected?",options: [ {text:"5-10% - minimal improvement from reduced handshakes",feedback:"Incorrect. This underestimates the impact of 0-RTT. The formula T_active = n × k × t shows that dropping from k=2.5 (HTTP/2) to k=1.0 (HTTP/3 0-RTT) is a 60% reduction in active time, translating to 30-50%+ in real-world power savings — much more than 5-10%."}, {text:"30-50% - significant reduction in radio active time",feedback:"Correct! HTTP/3's 0-RTT reduces the RTT multiplier from ~2.5 (TCP+TLS) to ~1.0 for resumed connections. With 96 wake cycles/day at 100ms RTT, active time drops from 24s to 9.6s — approximately a 60% reduction in connection overhead, yielding 30-50% battery savings in practice."}, {text:"80-90% - nearly eliminates connection overhead",feedback:"Incorrect. While 0-RTT dramatically reduces handshake overhead, it does not eliminate it entirely. The device still needs time for data transfer itself, QUIC crypto operations, and the response RTT. In practice, the reduction is 30-50%, not 80-90%, because data transfer time remains constant regardless of protocol."}, {text:"No difference - both protocols require the same handshake",feedback:"Incorrect. This is the opposite of the truth. HTTP/2 uses TCP+TLS which requires at minimum 2 RTTs before sending data. HTTP/3 QUIC with 0-RTT session resumption sends encrypted data in the very first packet (0 extra RTTs for reconnection), directly reducing how long the cellular radio must stay active."} ],correctIndex:1,explanation:"HTTP/3's 0-RTT resumption can reduce radio active time by 30-50% for cellular IoT devices. Traditional TCP+TLS requires 2-3 round trips before sending data (~200-400ms on cellular), keeping the radio active and draining battery. QUIC's 0-RTT allows the device to send encrypted data immediately in the first packet, significantly reducing the time the cellular modem must remain powered.",difficulty:"advanced"})
Show code
InlineKnowledgeCheck({containerId:"kc-http-modern-4",question:"An ESP32-based sensor node with 320KB RAM needs to communicate with a cloud REST API. What is the PRIMARY constraint when choosing between HTTP/2 and HTTP/3?",options: [ {text:"HTTP/2 requires more RAM than HTTP/3",feedback:"Incorrect — this reverses the relationship. HTTP/2 requires approximately 32KB for HPACK header tables and stream state, while HTTP/3 needs roughly 64KB for QUIC connection state and integrated cryptographic context. HTTP/3 is the more memory-hungry option."}, {text:"HTTP/3 requires ~64KB RAM for QUIC state vs ~32KB for HTTP/2",feedback:"Correct! HTTP/3's QUIC transport needs ~64KB for connection metadata and crypto state, versus ~32KB for HTTP/2's HPACK tables and stream management. With 320KB on the ESP32, both are technically feasible, but HTTP/3 leaves 32KB less for application logic, sensor drivers, and buffers — a real constraint on embedded systems."}, {text:"Both protocols have identical memory requirements",feedback:"Incorrect. The memory footprints differ meaningfully: HTTP/2 needs ~32KB (HPACK tables + stream state) while HTTP/3 needs ~64KB (QUIC connection state + integrated TLS context). On a 320KB device this 32KB difference represents 10% of total RAM — significant when competing with sensor buffers, network stacks, and application code."}, {text:"ESP32 cannot support either HTTP/2 or HTTP/3",feedback:"Incorrect. The ESP32 with 320KB SRAM can support both HTTP/2 (requires ~32KB) and HTTP/3 (requires ~64KB), leaving ample room for the application. The 32KB RAM threshold only applies to HTTP/1.1 minimum; devices under that threshold should use CoAP or MQTT instead. ESP-IDF already provides partial HTTP/2 support via nghttp2."} ],correctIndex:1,explanation:"HTTP/3 requires approximately 64KB RAM for QUIC connection and cryptographic state, while HTTP/2 needs about 32KB for HPACK tables and stream state. With 320KB RAM on an ESP32, both are feasible, but HTTP/3's higher memory footprint may leave less room for application code. For memory-constrained scenarios, HTTP/2 provides a good balance of modern features with lower overhead.",difficulty:"intermediate"})
Show code
InlineKnowledgeCheck({containerId:"kc-http-modern-5",question:"A company's enterprise network blocks UDP traffic at the firewall. What should the IoT architect recommend for their smart building gateway that needs to use HTTP-based APIs?",options: [ {text:"Use HTTP/3 and request the firewall be reconfigured",feedback:"Incorrect. Requesting firewall reconfiguration in an enterprise environment is a process that can take weeks or months, introduces security review overhead, and may be rejected outright. An architect should work within the existing network constraints, not around them. HTTP/2 over TCP is available immediately with no firewall changes."}, {text:"Use HTTP/2 over TCP - it provides multiplexing benefits without requiring UDP",feedback:"Correct! HTTP/2 runs over TCP (port 443), which enterprise firewalls universally allow. It still delivers multiplexing (all sensor requests on one connection), HPACK header compression (90% reduction), and server push — major improvements over HTTP/1.1, all without needing UDP."}, {text:"Use HTTP/1.1 with multiple parallel connections",feedback:"Incorrect. HTTP/1.1 with 6-8 parallel connections is less efficient than HTTP/2 multiplexing because each connection requires its own TCP+TLS handshake. With 50 sensors, you still need multiple batches of connections. HTTP/2 achieves everything HTTP/1.1 connection pooling does plus more, all over a single TCP connection."}, {text:"Switch to CoAP instead of HTTP",feedback:"Incorrect. The question specifies the gateway needs to use HTTP-based APIs — switching to CoAP would require changing the cloud backend which is not an option here. Additionally, CoAP uses UDP port 5683, which would also be blocked by the same UDP-blocking firewall policy, making it doubly unsuitable."} ],correctIndex:1,explanation:"HTTP/2 is the best choice when UDP is blocked because it runs over TCP and still provides significant benefits over HTTP/1.1: multiplexing (parallel requests over single connection), HPACK header compression (90% reduction), and server push. HTTP/3 requires UDP for QUIC transport, so it won't work through firewalls that block UDP. For enterprise environments with strict firewall policies, HTTP/2 is often the practical choice.",difficulty:"intermediate"})
Show code
InlineKnowledgeCheck({containerId:"kc-http-modern-6",question:"An IoT gateway is sending both real-time sensor telemetry (temperature readings every second) and firmware updates (large binary chunks) over the same HTTP/2 connection. A packet from the firmware download is lost. What happens?",options: [ {text:"Only the firmware stream pauses while waiting for retransmission; telemetry continues unaffected",feedback:"Incorrect — this describes HTTP/3 QUIC behaviour, not HTTP/2. HTTP/2 multiplexes streams at the application layer, but the underlying TCP transport delivers bytes in strict order. A lost firmware packet blocks ALL bytes behind it in the TCP receive buffer, including telemetry bytes, until the lost packet is retransmitted. This transport-layer head-of-line blocking is HTTP/2's key limitation."}, {text:"All streams pause because HTTP/2 uses TCP, which has head-of-line blocking at the transport layer",feedback:"Correct! HTTP/2 provides application-layer multiplexing, but TCP guarantees in-order, reliable delivery. A single lost firmware packet blocks the TCP receive window for ALL streams sharing that connection — both firmware and telemetry stall until retransmission completes. HTTP/3 QUIC solves this by making each stream independent at the transport layer."}, {text:"The connection is dropped and must be re-established",feedback:"Incorrect. A single lost packet does NOT drop the TCP connection. TCP's retransmission mechanism recovers the lost packet without terminating the connection. However, all data in the TCP receive buffer behind the lost packet is delayed (head-of-line blocked) until the retransmission arrives — the connection persists but all streams stall."}, {text:"HTTP/2 automatically prioritizes telemetry over firmware",feedback:"Incorrect. HTTP/2 does support stream priority hints (PRIORITY frames), but priority only influences how the sender allocates bandwidth between streams — it does NOT bypass TCP's head-of-line blocking. Once a packet is lost, TCP forces all streams to wait regardless of their priority settings, because TCP delivers bytes in order."} ],correctIndex:1,explanation:"This is a key limitation of HTTP/2: while it provides application-layer multiplexing, it still runs over TCP. TCP's reliable, in-order delivery means that when a packet is lost, ALL data behind that packet must wait for retransmission - this is called head-of-line (HOL) blocking. In this scenario, even though the telemetry streams are logically independent, they're blocked by the firmware packet loss at the TCP layer. HTTP/3 solves this by using QUIC, which provides independent streams at the transport layer.",difficulty:"advanced"})
Show code
InlineKnowledgeCheck({containerId:"kc-http-modern-7",question:"A startup is building an agricultural IoT system with soil moisture sensors. The sensors have 16KB RAM, connect via LoRaWAN to a gateway (512KB RAM), which then communicates with their AWS cloud backend. Which protocol combination is MOST appropriate?",options: [ {text:"Sensors use HTTP/2 to gateway, gateway uses HTTP/3 to cloud",feedback:"Incorrect. HTTP/2 requires ~32KB RAM minimum — twice what the 16KB sensors have. Additionally, LoRaWAN is an ultra-low-bandwidth link (250 bps to 50 kbps) designed for tiny payloads, not HTTP/2's binary framing and HPACK tables. Using HTTP at the sensor level is technically infeasible here."}, {text:"Sensors use CoAP to gateway, gateway uses HTTP/2 to cloud",feedback:"Correct! CoAP is designed for constrained devices (16KB RAM is fine) and works natively over LoRaWAN's low-bandwidth links. The 512KB gateway easily runs HTTP/2, providing efficient multiplexed uploads to AWS. This architecture correctly matches protocol complexity to device capability at each tier."}, {text:"All devices use HTTP/3 for consistency",feedback:"Incorrect. HTTP/3 requires ~64KB RAM and is built on QUIC over UDP. The 16KB sensors cannot run it, and LoRaWAN's tiny frame sizes (51-222 bytes) make QUIC's connection establishment infeasible. Protocol consistency is a nice-to-have but never at the cost of feasibility — use the right protocol for each tier."}, {text:"Sensors use HTTP/1.1 to gateway, gateway uses HTTP/2 to cloud",feedback:"Incorrect. HTTP/1.1 has a minimal RAM footprint (~8KB), but LoRaWAN links are far too narrow (250 bps–50 kbps, ~51-222 byte max frame) to carry HTTP/1.1's verbose text headers (350+ bytes per request). HTTP/1.1 headers alone would exceed the LoRaWAN frame size. CoAP was specifically designed for constrained links like LoRaWAN."} ],correctIndex:1,explanation:"The optimal architecture matches protocol complexity to device capability. The 16KB RAM sensors cannot support HTTP (minimum ~32KB for HTTP/2) - they need a lightweight protocol like CoAP over LoRaWAN. The 512KB gateway can easily support HTTP/2, which provides excellent performance for aggregating and uploading sensor data to AWS. HTTP/2 is preferred over HTTP/3 here because AWS IoT has mature HTTP/2 support and the gateway-to-cloud link is typically stable.",difficulty:"intermediate"})
Matching Quiz: HTTP/2 and HTTP/3 Concepts
Match each HTTP/2 or HTTP/3 concept to its correct definition or IoT benefit.
🧠 Knowledge Check
🏷️ Label the Diagram
📝 Order the Steps
7.12 Summary and Key Takeaways
What You Learned
This chapter covered the evolution of HTTP protocols and their applicability to IoT scenarios:
HTTP/2 Benefits:
Multiplexing enables 50x faster gateway scenarios by sending all requests over a single TCP connection
HPACK compression reduces header overhead by 90%, critical for chatty IoT applications
Server push enables efficient firmware distribution without client polling
Single TCP connection reduces TLS handshake overhead for persistent connections
HTTP/3 Benefits:
0-RTT resumption: 30-50% power savings for cellular IoT devices waking from sleep
Independent streams: No head-of-line blocking - packet loss in one stream doesn’t affect others
Connection migration: Survives network handoff (cell tower switches) for mobile assets
Key Insight: HTTP/2 and HTTP/3 don’t replace MQTT or CoAP for constrained IoT devices, but they significantly improve HTTP performance for gateways, cloud integration, and mobile IoT scenarios where HTTP infrastructure already exists.
Summary: When to Use Modern HTTP Protocols
Figure 7.14: Summary: When to Use Modern HTTP Protocols
For Instructors: Teaching Suggestions
Lab Exercise Ideas:
HTTP/2 Multiplexing Demo: Use curl --http2 with timing to compare 10 sequential vs. parallel requests
Header Compression Measurement: Capture HTTP/1.1 vs HTTP/2 traffic with Wireshark to measure header size reduction
0-RTT Latency Test: Configure a QUIC server and measure first-request latency for new vs. resumed connections
Discussion Questions:
Why might an enterprise prefer HTTP/2 over HTTP/3 even when UDP is available?
How does QUIC’s connection migration feature change the design of mobile IoT applications?
What are the security implications of 0-RTT early data?
Common Student Misconceptions:
“HTTP/3 is always faster” - Not true; on stable networks with low loss, HTTP/2 performs similarly
“HTTP/2 needs multiple connections” - The whole point is single connection with multiplexing
“Modern HTTP works on any device” - Memory constraints often make it impractical for constrained sensors
Concept Relationships
Understanding HTTP/2 and HTTP/3 connects to several other protocol and networking concepts: