-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhaproxy-standby.cfg
More file actions
79 lines (69 loc) · 2.5 KB
/
Copy pathhaproxy-standby.cfg
File metadata and controls
79 lines (69 loc) · 2.5 KB
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# haproxy-standby exposes the CLIENT-FACING ports (11040-11043) for the
# Enterprise active/standby standalone pair and routes traffic ONLY to the
# elected leader.
#
# Each enterprise standalone exposes /status/standalone/is_leader:
# - HTTP 200 when this node is the ready leader
# - HTTP 503 (SERVICE_UNAVAILABLE) when it is a follower
# haproxy treats 2xx as UP and 503 as DOWN, so only the leader backend is ever
# marked available — exactly the active/standby routing we want.
#
# standby-a -> 127.0.0.1:11070 (http) / 11071 (grpc) / 11072 (mysql) / 11073 (pg)
# standby-b -> 127.0.0.1:11074 (http) / 11075 (grpc) / 11076 (mysql) / 11077 (pg)
#
# This binds the same client-facing ports 11040-11043 as haproxy / standalone /
# standalone-fs, so it is mutually exclusive with those modes (never run them at
# the same time). Client code (psql/mysql/http) works identically everywhere.
#
# NOTE: requires an ENTERPRISE greptime binary — /status/standalone/is_leader is
# an enterprise-only endpoint.
global
maxconn 256
defaults
mode tcp
timeout connect 5s
timeout client 10m
timeout server 10m
retries 3
frontend fe_http
bind *:11040
mode http
default_backend be_http
frontend fe_grpc
bind *:11041
default_backend be_grpc
frontend fe_mysql
bind *:11042
default_backend be_mysql
frontend fe_postgres
bind *:11043
default_backend be_postgres
# HTTP backend: health-check the leader endpoint directly on the HTTP port.
backend be_http
mode http
option httpchk GET /status/standalone/is_leader
http-check expect status 200
server standby-a 127.0.0.1:11070 check
server standby-b 127.0.0.1:11074 check
# TCP backends: route client TCP to the service port, but health-check the
# leader endpoint on each node's HTTP port (via `check port`). A node is only UP
# while it returns 200 from /status/standalone/is_leader, i.e. while it is the
# elected leader.
backend be_grpc
mode tcp
option httpchk GET /status/standalone/is_leader
http-check expect status 200
server standby-a 127.0.0.1:11071 check port 11070
server standby-b 127.0.0.1:11075 check port 11074
backend be_mysql
mode tcp
option httpchk GET /status/standalone/is_leader
http-check expect status 200
server standby-a 127.0.0.1:11072 check port 11070
server standby-b 127.0.0.1:11076 check port 11074
backend be_postgres
mode tcp
option httpchk GET /status/standalone/is_leader
http-check expect status 200
server standby-a 127.0.0.1:11073 check port 11070
server standby-b 127.0.0.1:11077 check port 11074