WebSocket and HTTP/2 Support
What you'll learn: How Application Load Balancers handle persistent WebSocket connections and leverage HTTP/2 for faster, more efficient communication.
The Problem with Traditional HTTP
Remember that HTTP requests are typically short-lived: request, response, done. But some applications need persistent, two-way communication (like chat apps or real-time dashboards). HTTP/2 also improves performance by allowing multiple requests over a single connection instead of opening many separate ones.
WebSocket Support
WebSocket is a protocol that keeps a connection open between client and server, allowing both sides to push messages whenever needed—no repeated polling required.
When you enable WebSocket on your ALB, it:
- Automatically detects WebSocket upgrade requests (where HTTP switches to WebSocket mode)
- Maintains these long-lived connections without timing them out prematurely
- Routes WebSocket traffic just like HTTP traffic using the same target groups and routing rules
Analogy: Instead of writing separate letters back and forth (traditional HTTP), WebSocket is like opening a phone line that stays connected for an ongoing conversation.
HTTP/2 Support
HTTP/2 allows multiplexing—sending multiple requests and responses simultaneously over one TCP connection, rather than opening separate connections for each resource.
ALBs support HTTP/2 between the client and load balancer by default (though connections to backend targets remain HTTP/1.1). This means:
- Faster page loads with parallel resource fetching
- Reduced connection overhead
- Header compression for efficiency
No special configuration needed—HTTP/2 works automatically when clients support it.
Key Takeaway: ALBs transparently handle WebSocket's persistent connections for real-time apps and automatically use HTTP/2 for performance gains, making your applications faster and more interactive without complex backend changes.