5

Currently, we have 200 containers(several different applications) running in mesos-marathon cluster. This is behind the HAproxy instances and works on HTTP/HTTPS protocol.

Internet --> AWS ELB --> HAProxy --> Docker containers

Now we have a requirement to make one existing application to run on WEBSOCKET protocol. We are thinking to add new AWS ALB to achieve this. Hence the setup will be like

        (WebSocket)
Internet --> new AWS ALB --> HAProxy --> Docker containers

        (HTTP/S)
Internet -->  AWS ELB  --> HAProxy --> Docker containers

What setting do we need to make so that HAproxy will work with current HTTP/S and also new WEBSOCKET?

ExploringApple
  • 1,348
  • 2
  • 17
  • 30

2 Answers2

-1

The server can handle 65,536 sockets per single IP address. So the quantity can be easily extended by adding additional network interfaces to a server. Meanwhile, it’s extremely important to track how many connections present on a server. Once the limit is exceeded, you can have a lot of issues with other TCP connections (e.g. it’s not possible to connect to a server via ssh). So it’s a good idea to limit WS connections per node inside your application’s code.

To make HAProxy handle more than 65k connections we should pass through the next steps::

  1. Create a bunch of private IP addresses. To do it choose your Amazon Instance -> Actions -> Networking -> Manage Private IP Addresses. We added 3 IP addresses: 192.168.1.1, 192.168.1.2, 192.168.1.3. Just remember that the IP should be in the same sub-network as your real application server.
  2. Connect to your HAProxy instance via SSH and run following commands:

    $> ifconfig eth0:1 192.168.1.1

    $> ifconfig eth0:2 192.168.1.2

    $> ifconfig eth0:3 192.168.1.3

This will add 3 virtual network interfaces to the instance.

  1. Configure HAProxy. Here is a section from haproxy.cfg file for 3 nodes accepting WS connections:

    listen erlang_front :8888

    mode        http
    
    balance     roundrobin
    
    timeout connect 1s
    
    timeout queue 5s
    
    timeout server 3600s
    
    option httpclose
    
    option forwardfor
    
    server      xxxxx-1 192.168.0.1:8888  source 192.168.1.1
    
    server      xxxxx-2 192.168.0.2:8888  source 192.168.1.2
    
    server      xxxxx-3 192.168.0.3:8888  source 192.168.1.3
    

Now HAProxy can handle more than 65,536 WebSocket connections, and the limit of connections can be easily increased by adding virtual network interfaces. Also, it can establish new connections rather fast.

Also Refer this Blog Post

Kush Vyas
  • 5,813
  • 2
  • 26
  • 36
-1

It sounds like you would benefit from using the new Network Load Balancer instead of the classic Elastic Load Balancer or the Application Load Balancer.

The NLB can handle (according to AWS) 10's of millions of requests per second, and supports long-lived connections.

chris
  • 36,094
  • 53
  • 157
  • 237