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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
# =============================================================================
# HeliosProxy - Minimal Example Configuration
# =============================================================================
#
# A starter configuration for HeliosProxy with one primary and one standby
# node using transaction pooling. Copy this file to proxy.toml and edit to
# match your environment.
#
# Environment variable substitution: use ${VAR_NAME:-default_value} syntax.
# All addresses, credentials, and tuning parameters support env var overrides.
#
# Documentation: https://github.com/heliosdb/proxy
# -----------------------------------------------------------------------------
# Proxy listener settings
# -----------------------------------------------------------------------------
# Address the proxy listens on for PostgreSQL client connections.
# Clients connect here instead of directly to the database.
= "${HELIOS_PROXY_LISTEN:-0.0.0.0:6432}"
# Address for the admin REST API (health checks, metrics, reload).
= "${HELIOS_PROXY_ADMIN:-0.0.0.0:9090}"
# Transaction Replay (TR) — automatically replays in-flight transactions
# after a failover so clients see no errors.
# Disable if you handle retries at the application level.
= false
= "session" # none | session | select | transaction
# Maximum time (seconds) to wait for a new primary during failover before
# returning an error to the client.
= 30
# -----------------------------------------------------------------------------
# Connection pool — controls backend (proxy -> database) connections
# -----------------------------------------------------------------------------
[]
# Minimum backend connections kept open per node (warm pool).
= 5
# Maximum backend connections per node. Size this based on your database's
# max_connections minus headroom for admin/replication connections.
= ${HELIOS_PROXY_POOL_MAX:-50}
# Close idle backend connections after this many seconds.
= 300
# Recycle backend connections after this many seconds regardless of activity.
# Prevents issues with firewall/load-balancer idle timeouts.
= 1800
# How long a client waits to acquire a backend connection before getting an
# error. Keep this short to fail fast under load.
= 5
# Run a quick query before handing a connection to a client to make sure
# it is still alive. Small overhead, high reliability.
= true
# -----------------------------------------------------------------------------
# Pool mode — determines when connections are returned to the pool
# -----------------------------------------------------------------------------
[]
# Pooling mode:
# session — 1:1 mapping, connection held for the entire client session.
# Safest; allows SET, LISTEN/NOTIFY, temp tables.
# transaction — connection returned after COMMIT/ROLLBACK. Best throughput
# for most web applications.
# statement — connection returned after every statement. Maximum reuse,
# but no multi-statement transactions or prepared statements.
= "${HELIOS_PROXY_POOL_MODE:-transaction}"
# Maximum pool connections per node (pool_mode layer).
= 50
# Keep at least this many idle connections ready.
= 5
# Idle / lifetime / acquire timeouts (seconds).
= 300
= 1800
= 5
# SQL executed when a connection is returned to the pool to reset session
# state. DISCARD ALL is the safest choice for transaction mode.
= "DISCARD ALL"
# How prepared statements are handled across pooled connections:
# disable — never use prepared statements (safest for statement mode)
# track — proxy tracks and re-creates them transparently (recommended
# for transaction mode)
# named — use protocol-level named statements (best for session mode)
= "track"
# Validate connections with this query before handing them to a client.
= "SELECT 1"
# -----------------------------------------------------------------------------
# Load balancer — read/write splitting and strategy
# -----------------------------------------------------------------------------
[]
# Strategy for distributing read queries across standbys:
# round_robin — cycle through nodes evenly
# weighted_round_robin — use node weight values
# least_connections — send to the node with fewest active connections
# latency_based — send to the node with lowest measured latency
# random — random selection
= "round_robin"
# When true, SELECT queries are routed to standbys and writes to the primary.
# Disable if your application cannot tolerate any replication lag on reads.
= true
# If a node's average response time exceeds this threshold (milliseconds)
# it is temporarily deprioritised for read traffic.
= 100
# -----------------------------------------------------------------------------
# Health checks — monitor backend node availability
# -----------------------------------------------------------------------------
[]
# Seconds between health check probes.
= 5
# Maximum seconds a health check query may take before it counts as a failure.
= 3
# A node is marked unhealthy after this many consecutive check failures.
= 3
# A previously-unhealthy node must pass this many consecutive checks to be
# marked healthy again.
= 2
# The SQL query used as a health check. SELECT 1 works on all PostgreSQL
# versions. For deeper checks, consider pg_is_in_recovery() or custom queries.
= "SELECT 1"
# -----------------------------------------------------------------------------
# Backend nodes — define your database cluster
# -----------------------------------------------------------------------------
# Primary node — handles all writes and can serve reads.
[[]]
= "${HELIOS_PROXY_PRIMARY_HOST:-db-primary}"
= 5432
= "primary" # primary | standby | replica
= 100 # relative weight for weighted_round_robin
= true
# Standby node — serves read traffic when read_write_split is enabled.
[[]]
= "${HELIOS_PROXY_STANDBY1_HOST:-db-standby1}"
= 5432
= "standby"
= 100
= true
# -----------------------------------------------------------------------------
# Cache — query result caching (disabled in this minimal config)
# -----------------------------------------------------------------------------
[]
= false
# -----------------------------------------------------------------------------
# High availability
# -----------------------------------------------------------------------------
[]
= true
= true
= 3 # health check failures before failover
= 100 # max replication lag for read routing
# -----------------------------------------------------------------------------
# Logging
# -----------------------------------------------------------------------------
[]
# Log level: trace | debug | info | warn | error
= "${HELIOS_PROXY_LOG_LEVEL:-info}"
# Output format: pretty (human-readable) | compact | json
= "pretty"
# -----------------------------------------------------------------------------
# Prometheus metrics
# -----------------------------------------------------------------------------
[]
= true
= "0.0.0.0:9100"