-
Notifications
You must be signed in to change notification settings - Fork 33
/
Copy pathhaproxy_example.cfg
64 lines (54 loc) · 1.74 KB
/
haproxy_example.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# Sample haproxy config for the example app running 4 workers (on 9002 - 9005)
# Run with haproxy -f haproxy_example.cfg
global
maxconn 2000
nbproc 1
cpu-map 1 0
log 127.0.0.1 local0
# by default huge buffers are allocated per backend for storing health check
# results. Reduce to save memory, especially when not doing string matching
tune.chksize 128
defaults
log global
option dontlognull
option log-separate-errors
maxconn 2000
# connect timeout on localhost doesn't matter
timeout connect 5s
# adjust this based on how long you can tolerate a request queueing. Kept
# high for the example to demonstrate the impact of queue.
timeout queue 5s
timeout check 5s
# client and server timeouts should be kept high as haproxy will decrement
# the sessions for a backend when the timeout expires. The backend will
# probably still be processing the request at the timeout, so sending a new
# request its way would be bad. This should possibly be infinite, but 60s
# should be safe enough with timeouts on the client, especially when
# stronger process supervision is added.
timeout client 60s
timeout server 60s
# enables trying new backends on connection failure
option redispatch
retries 3
balance static-rr
option http-keep-alive
listen stats_nbproc1 :8999
mode http
stats enable
stats uri /
bind-process 1
# example app backends
frontend example
mode http
option httplog
bind :9001
default_backend example
backend example
mode http
option httplog
option tcplog
# run 4 workers
server worker1 127.0.0.1:9002 maxconn 1
server worker2 127.0.0.1:9003 maxconn 1
server worker3 127.0.0.1:9004 maxconn 1
server worker4 127.0.0.1:9005 maxconn 1