Application Protocols · Study deck
HTTP Pitfalls: Migration and Recovery
HTTP looks simple until a small device pays for every poll, handshake, retry, oversized payload, and reconnect storm.
Broker Bex is your guide for this deck.

After studying this chapter
Learning objectives
You will be able to:
- Explain: The difference identifies setup reuse as the lever, while the notes prevent overclaiming: TLS version and resumption alter the exchange, intermediaries limit keep-alive, and early data has replay constraints.
- Explain: The client sends ClientHello, the server returns ServerHello plus its certificate, the client responds with key exchange plus Finished, and the server completes the handshake with its own Finished.
- Explain: A practical rollout records idle timeout, heartbeat interval, reconnect rate, radio-on time, and session-reuse rate, then chooses the cheapest setting that keeps useful sessions alive.
- design retry and recovery behavior with measurable limits
Major section
Worked Example: Protocol Migration Cost-Benefit Analysis
Scenario:: A fleet management company operates 5,000 GPS trackers on delivery vehicles.
- Each tracker sends location updates every 30 seconds via HTTPS POST to a cloud API.
- The CTO notices excessive cellular data costs and asks the engineering team to evaluate alternatives.
- Per-update overhead: MQTT PUBLISH header 14 bytes, binary GPS payload 9 bytes, keep-alive 2 bytes every 60 seconds.
Major section
Deep Dive: What One HTTPS Request Really Costs
On a battery-powered device over a cellular link, the payload is rarely the expensive part.
- A 20-byte reading can be preceded by radio wake, TCP connection setup, TLS negotiation, certificate validation, and the HTTP request/response round trip.
- On the warm path, the established secure connection lets HTTP begin immediately.
Major section
Deep Dive: What One HTTPS Request Really Costs (continued)
On a 100-300 ms round-trip path, that setup can keep the radio active for seconds before the tiny payload moves.
- The difference identifies setup reuse as the lever, while the notes prevent overclaiming: TLS version and resumption alter the exchange, intermediaries limit keep-alive, and early data has replay constraints.
- The TLS 1.3 handshake is one round trip.
- The other framing detail that trips up gateways is chunked transfer encoding.
Major section
Deep Dive: What One HTTPS Request Really Costs (continued)
Process chunk by chunk and cap the total accepted size instead of trusting the sender to stop.
- A practical rollout records idle timeout, heartbeat interval, reconnect rate, radio-on time, and session-reuse rate, then chooses the cheapest setting that keeps useful sessions alive.
- TLS 1.2 usually needs another round trip for the extra key-exchange step.
- For a field review, keep one cold-start trace and one warm-session trace.
Major section
How It Works: HTTP Connection Lifecycle
The client sends SYN, the server replies with SYN-ACK, and the client finishes with ACK; then: Step 2: TLS 1.2 handshake (2 RTT).
- The client sends GET /sensor/data, then the server returns 200 OK and the payload; and finish with: Total before data arrives: typically 4 to 5 RTT.
- The client sends SYN, the server replies with SYN-ACK, and the client finishes with ACK.
- The client sends ClientHello, the server returns ServerHello plus its certificate, the client responds with key exchange plus Finished, and the server completes the handshake with its own Finished.
Deck summary
Key takeaways
Scenario:: A fleet management company operates 5,000 GPS trackers on delivery vehicles.
- On a battery-powered device over a cellular link, the payload is rarely the expensive part.
- On a 100-300 ms round-trip path, that setup can keep the radio active for seconds before the tiny payload moves.
- Process chunk by chunk and cap the total accepted size instead of trusting the sender to stop.
- The client sends SYN, the server replies with SYN-ACK, and the client finishes with ACK; then: Step 2: TLS 1.2 handshake (2 RTT).
Retrieval practice
Recall check 1 of 4

Broker Bex says: answer from memory, then check your reasoning.
Q1Complete the HTTP connection management for IoT polling:
Show answer
Answer: A Using requests.Session() enables HTTP keep-alive connection reuse, reducing TCP handshake overhead for repeated API calls. Always set timeout to prevent hanging on unreachable IoT devices. Session headers persist across all requests.
Retrieval practice
Recall check 2 of 4

Broker Bex says: answer from memory, then check your reasoning.
Q2Place each HTTP connection concern where it lives so you can cut handshake waste without creating a blocked queue or exhausting a constrained gateway.
Show answer
Answer: A Place each HTTP connection concern where it lives so you can cut handshake waste without creating a blocked queue or exhausting a constrained gateway.
Retrieval practice
Recall check 3 of 4

Broker Bex says: answer from memory, then check your reasoning.
Q3An IoT gateway sends temperature readings from 50 sensors to a cloud API using HTTP POST requests -- one request per sensor every 10 seconds. Each request creates a new TCP+TLS connection. The gateway's latency is unexpectedly high (800ms per request) despite a fast network. What is the primary cause and best fix?
Show answer
Answer: D
Retrieval practice
Recall check 4 of 4

Broker Bex says: answer from memory, then check your reasoning.
Q4After a server restart, 500 IoT dashboard WebSocket clients all attempt to reconnect simultaneously, crashing the server. What reconnection strategy prevents this "thundering herd" problem?
Show answer
Answer: C Exponential backoff with random jitter spreads reconnection attempts over time.
Print reference
Answers
Answer key.
- A · Using requests.Session() enables HTTP keep-alive connection reuse, reducing TCP handshake overhead for repeated API calls. Always set timeout to prevent hanging on unreachable IoT devices. Session headers persist across all requests.
- A · Place each HTTP connection concern where it lives so you can cut handshake waste without creating a blocked queue or exhausting a constrained gateway.
- D
- C · Exponential backoff with random jitter spreads reconnection attempts over time.