Skip to content

Commit 1f0ac50

Browse files
committed
Add "haproxy_maxconn" and "haproxy_timeout" variables.
Issue vitabaks#99
1 parent 1887ffa commit 1f0ac50

File tree

3 files changed

+26
-19
lines changed

3 files changed

+26
-19
lines changed

roles/confd/templates/haproxy.tmpl.j2

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
global
2-
maxconn 100000
2+
maxconn {{ haproxy_maxconn.global }}
33
log /dev/log local0
44
log /dev/log local1 notice
55
chroot /var/lib/haproxy
@@ -8,7 +8,7 @@ global
88
user haproxy
99
group haproxy
1010
daemon
11-
11+
1212
defaults
1313
mode tcp
1414
log global
@@ -18,20 +18,20 @@ defaults
1818
timeout client 60m
1919
timeout server 60m
2020
timeout check 15s
21-
21+
2222
listen stats
2323
mode http
2424
bind {{ hostvars[inventory_hostname]['inventory_hostname'] }}:7000
2525
stats enable
2626
stats uri /
27-
27+
2828
listen master
2929
{% if cluster_vip is defined and cluster_vip | length > 0 %}
3030
bind {{ cluster_vip }}:5000
3131
{% else %}
3232
bind {{ hostvars[inventory_hostname]['inventory_hostname'] }}:5000
3333
{% endif %}
34-
maxconn 10000
34+
maxconn {{ haproxy_maxconn.master }}
3535
option tcplog
3636
option httpchk OPTIONS /master
3737
http-check expect status 200
@@ -52,7 +52,7 @@ listen replicas
5252
{% else %}
5353
bind {{ hostvars[inventory_hostname]['inventory_hostname'] }}:5001
5454
{% endif %}
55-
maxconn 10000
55+
maxconn {{ haproxy_maxconn.replica }}
5656
option tcplog
5757
option httpchk OPTIONS /replica
5858
balance roundrobin
@@ -74,7 +74,7 @@ listen replicas_sync
7474
{% else %}
7575
bind {{ hostvars[inventory_hostname]['inventory_hostname'] }}:5002
7676
{% endif %}
77-
maxconn 10000
77+
maxconn {{ haproxy_maxconn.replica }}
7878
option tcplog
7979
option httpchk OPTIONS /sync
8080
balance roundrobin
@@ -96,7 +96,7 @@ listen replicas_async
9696
{% else %}
9797
bind {{ hostvars[inventory_hostname]['inventory_hostname'] }}:5003
9898
{% endif %}
99-
maxconn 10000
99+
maxconn {{ haproxy_maxconn.replica }}
100100
option tcplog
101101
option httpchk OPTIONS /async
102102
balance roundrobin

roles/haproxy/templates/haproxy.cfg.j2

+11-11
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
global
2-
maxconn 100000
2+
maxconn {{ haproxy_maxconn.global }}
33
log /dev/log local0
44
log /dev/log local1 notice
55
chroot /var/lib/haproxy
@@ -8,30 +8,30 @@ global
88
user haproxy
99
group haproxy
1010
daemon
11-
11+
1212
defaults
1313
mode tcp
1414
log global
1515
retries 2
1616
timeout queue 5s
1717
timeout connect 5s
18-
timeout client 60m
19-
timeout server 60m
18+
timeout client {{ haproxy_timeout.client }}
19+
timeout server {{ haproxy_timeout.server }}
2020
timeout check 15s
21-
21+
2222
listen stats
2323
mode http
2424
bind {{ hostvars[inventory_hostname]['inventory_hostname'] }}:7000
2525
stats enable
2626
stats uri /
27-
27+
2828
listen master
2929
{% if cluster_vip is defined and cluster_vip | length > 0 %}
3030
bind {{ cluster_vip }}:5000
3131
{% else %}
3232
bind {{ hostvars[inventory_hostname]['inventory_hostname'] }}:5000
3333
{% endif %}
34-
maxconn 10000
34+
maxconn {{ haproxy_maxconn.master }}
3535
option tcplog
3636
option httpchk OPTIONS /master
3737
http-check expect status 200
@@ -53,7 +53,7 @@ listen replicas
5353
{% else %}
5454
bind {{ hostvars[inventory_hostname]['inventory_hostname'] }}:5001
5555
{% endif %}
56-
maxconn 10000
56+
maxconn {{ haproxy_maxconn.replica }}
5757
option tcplog
5858
option httpchk OPTIONS /replica
5959
balance roundrobin
@@ -76,7 +76,7 @@ listen replicas_sync
7676
{% else %}
7777
bind {{ hostvars[inventory_hostname]['inventory_hostname'] }}:5002
7878
{% endif %}
79-
maxconn 10000
79+
maxconn {{ haproxy_maxconn.replica }}
8080
option tcplog
8181
option httpchk OPTIONS /sync
8282
balance roundrobin
@@ -92,14 +92,14 @@ server {{ hostvars[host]['ansible_hostname'] }} {{ hostvars[host]['inventory_hos
9292
server {{ hostvars[host]['ansible_hostname'] }} {{ hostvars[host]['inventory_hostname'] }}:{{ postgresql_port }} check port 8008
9393
{% endfor %}
9494
{% endif %}
95-
95+
9696
listen replicas_async
9797
{% if cluster_vip is defined and cluster_vip | length > 0 %}
9898
bind {{ cluster_vip }}:5003
9999
{% else %}
100100
bind {{ hostvars[inventory_hostname]['inventory_hostname'] }}:5003
101101
{% endif %}
102-
maxconn 10000
102+
maxconn {{ haproxy_maxconn.replica }}
103103
option tcplog
104104
option httpchk OPTIONS /async
105105
balance roundrobin

vars/main.yml

+7
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,13 @@ synchronous_node_count: 1 # number of synchronous standby databases
2828

2929
# Load Balancing
3030
with_haproxy_load_balancing: false # or 'true' if you want to install and configure the load-balancing
31+
haproxy_maxconn:
32+
global: 100000
33+
master: 10000
34+
replica: 10000
35+
haproxy_timeout:
36+
client: "60m"
37+
server: "60m"
3138

3239
# vip-manager (if cluster_vip is specified and with_haproxy_load_balancing: false)
3340
vip_manager_version: "1.0" # version to install

0 commit comments

Comments
 (0)