728x90
반응형
Load Balancing with HAProxy on Docker
Setup
HAProxy + Socket.io + Node
HAProxy Config
haproxy.cfg
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | global maxconn 4096 defaults mode http balance roundrobin option redispatch option forwardfor timeout connect 5s timeout queue 5s timeout client 50s timeout server 50s listen stats bind *:1936 mode http stats enable stats uri /stats stats auth guest:guest stats refresh 5s frontend http-in bind *:8000 # check request ws acl acl backend_ws path_beg /socket.io acl backend_ws hdr(Upgrade) -i webSocket acl backend_ws hdr_beg(Host) -i ws # if it is ws request , use websockets use_backend websockets if is_websocket # if it is http request, use webservers default_backend servers backend servers # web server server server1 [address]:[port] check #example #server server1 172.17.0.10:8080 check backend websockets # socket server balance source # if use balance to roundrobin, you have to use stick option option http-server-close option forceclose server ws-server1 [address]:[port] maxconn 30000 weight 1 maxconn 1024 check #example #server ws-server1 172.17.0.1:80 maxconn 30000 weight 1 maxconn 1024 check #server ws-server2 172.17.0.2:80 maxconn 30000 weight 1 maxconn 1024 check #server ws-server3 172.17.0.3:80 maxconn 30000 weight 1 maxconn 1024 check | cs |
Docker run HAProxy
1 | docker run -d -p 1936:1936 -p 8000:8000 --name docker-haproxy my-haproxy | cs |
reference - http://mydreamisthebestcooder.tistory.com/78
Test
Load test
1. Use websocket-bench
1 | $ websocket-bench -a 100 -c 20 ws://127.0.0.1:8000 | cs |
https://github.com/M6Web/websocket-bench
2. Use Socket.io test client
http://amritb.github.io/socketio-client-tool/
728x90
반응형
'Programming > Docker' 카테고리의 다른 글
docker file copy from container to host (0) | 2017.04.03 |
---|---|
Nginx on Docker (0) | 2017.03.30 |
HAProxy with Docker (0) | 2017.03.24 |
docker upgrade (error : The engine version is lesser than the minimum required by compose) (0) | 2016.07.18 |
docker-compose version upgrade (0) | 2016.07.18 |
댓글