Skip to content

Instantly share code, notes, and snippets.

@sega-yarkin
Created September 29, 2017 14:10
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save sega-yarkin/b81443f63266e41090e8cce0c819b72d to your computer and use it in GitHub Desktop.
Save sega-yarkin/b81443f63266e41090e8cce0c819b72d to your computer and use it in GitHub Desktop.
HAProxy configuration for RabbitMQ (as STOMP over WS)
###
# HAProxy configuration for Eventmq Web-node.
# Configured to serve:
# - 100k websocket connections
# - 2k (2% of WS) streaming connections (5k fullconn)
# - 100 (0.1% of WS) xhr connections (5k fullconn)
###
global
log 127.0.0.1 local2 info
cpu-map 1 0
pidfile /var/run/haproxy.pid
maxconn 110500
maxpipes 30000
maxconnrate 10000
maxsessrate 10000
user haproxy
group haproxy
daemon
# turn on stats unix socket
stats socket /var/lib/haproxy/stats level admin
defaults
mode http
log global
backlog 4096
option contstats
option http-keep-alive
option http-no-delay
option httplog
option splice-auto
option tcp-smart-accept
option tcp-smart-connect
retries 3
timeout check 10s
timeout client 1m
timeout client-fin 10s
timeout connect 1m
timeout http-request 10m
timeout http-keep-alive 5m
timeout queue 1m
timeout server 10m
timeout server-fin 10s
frontend front_stomp
description Incoming connections for STOMP service
bind *:88
mode http
maxconn 110500
#
# Capture some useful information into logs
#
capture cookie sid len 43
capture request header Host len 32
capture request header X-Real-IP len 15
capture request header X-Uniq-ID len 36
#
# Routing
#
acl is_stat path_beg /stats
acl is_mgr path /stomp/info
acl is_mgr path_beg /stomp/resources/
acl is_mgr path /stomp/iframe.html
acl is_ws path_end /websocket
acl is_strm path_end /xhr_streaming
use_backend back_stats if is_stat
use_backend back_mgr if is_mgr
use_backend back_ws if is_ws
use_backend back_strm if is_strm
default_backend back_xhr
#
# Disable logging stats requests
http-request set-log-level silent if is_stat
backend back_stats
description Serves /stats
no log
stats enable
stats uri /stats
stats show-legends
stats refresh 5s
stats show-node
stats admin if TRUE
backend back_mgr
description SBIS Web-node user creator
fullconn 200
timeout server 30s
http-check expect status 200
server rmq 127.0.0.1:8088 maxconn 30 check inter 1s rise 2 fall 1
backend back_xhr
description Serves all XHR-requests
fullconn 5000
timeout server 30s
option httpchk GET /stomp/info
http-check expect rstring ^{
server rmq 127.0.0.1:15674 maxconn 100 check inter 1s rise 2 fall 1
backend back_ws
description Serves websocket connections
fullconn 100000
timeout server 10m
option httpchk GET /stomp/info
http-check expect rstring ^{
server rmq1 127.0.2.1:15674 source 127.0.1.1 maxconn 50000 check inter 1s rise 2 fall 1
server rmq2 127.0.2.2:15674 source 127.0.1.2 maxconn 50000 check inter 1s rise 2 fall 1
backend back_strm
description Serves streaming connections
fullconn 5000
timeout server 10m
option httpchk GET /stomp/info
http-check expect rstring ^{
server rmq 127.0.0.1:15674 maxconn 2000 check inter 1s rise 2 fall 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment