Web Apps: WebSockets with AWS Elastic Load Balancing

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.

load_balancing_with_ELB.png

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.

Did you find this useful?  

Interested in getting tips, best practices and commentary delivered regularly? Click the button below to sign up for our blog and set your topic and frequency preferences.

Sign Me Up!

 

October 29, 2014 / Compute, Scalability, Amazon EC2, Uptime, AWS ELB

About the Author

Flux7 Labs
Find me on:

Join Us

Join thousands of technology enthusiasts, subscribe and get expert perspective in your inbox.

Connect With Us

Recent Posts

Categories