Web Apps: WebSockets with AWS Elastic Load Balancing

Oct 29, 2014 4:04:00 PM Flux7 Labs Compute, Scalability, Amazon EC2, Uptime, AWS ELB

Amazon Web Service (AWS) Elastic Load Balancing (ELB) is widely used to build highly available and highly scalable architectures. Nowadays, ELB is as common as EC2 is for many customers using AWS. And, Elastic Load Balancing supports the following protocols: HTTP, HTTPs, TCP and TCPs.

WebSocket is a protocol providing full-duplex communication channels over a single TCP connection. You can read more about WebSockets here.

For web applications, we use HTTP or HTTPS protocols with ELB for load sharing. But, AWS ELB with HTTP or HTTPS protocols doesn’t support the WebSockets. Your WebSockets communication gets blocked at ELB. It doesn’t pass through to the backend app servers. There is no official information from AWS as they support the WebSockets with HTTP and HTTPs protocols.

There are alternatives for ELB, such as HAProxy. But, with autoscaling, it’s not easy to dynamically add instances to HAProxy and remove them when scaling down occurs.

There is a workaround in using ELB without compromising the WebSockets. Use TCP as a Load Balancer and Proxy protocol while creating a Load Balancer. ELB with TCP protocol supports the WebSockets. We have successfully implemented this for our customers.


If you have an SSL certificate, then deploy it at the app server level. This way, ELB behaves as just a proxy and passes through all the communication as-is to the backend. The only downside with procedure is that you can’t terminate the HTTPS at the Load Balancer level. But, this doesn’t compromise your data security because all of the communication from the browser to the app server is encrypted if you deploy SSL at the app server.

There you have it. A quick run-through in regard to WebSockets with AWS Elastic Load Balancing

If you have any comments or questions, let us know! Share them with us in the comments section below.

Get Started with AWS

Receive AWS tips, DevOps best practices, news analysis, commentary and more. Sign up for our blog here and set your topic and frequency preferences. Or, download our guide on getting started with AWS, establishing a secure AWS enterprise architecture with Flux7 Landing Zones. 

Get Started Guide

Written by Flux7 Labs

Flux7 is the only Sherpa on the DevOps journey that assesses, designs, and teaches while implementing a holistic solution for its enterprise customers, thus giving its clients the skills needed to manage and expand on the technology moving forward. Not a reseller or an MSP, Flux7 recommendations are 100% focused on customer requirements and creating the most efficient infrastructure possible that automates operations, streamlines and enhances development, and supports specific business goals.

Subscribe Here!

Posts by Topic

see all

Recent Posts