@@ -12,22 +12,43 @@ PgBouncer port.
12
12
13
13
## How to load-balance queries between several servers?
14
14
15
- 1 . Use a TCP connection load-balancer. Either
15
+ PgBouncer does not have internal multi-host configuration.
16
+ It is possible via some external tools:
17
+
18
+ 1 . DNS round-robin. Use several IPs behind one DNS name. PgBouncer does
19
+ not look up DNS each time new connection is launched. Instead it
20
+ caches all IPs and does round-robin internally. Note: if there is
21
+ more than 8 IPs behind one name, the DNS backend must support EDNS0
22
+ protocol. See README for details.
23
+
24
+ 2 . Use a TCP connection load-balancer. Either
16
25
[ LVS] ( http://www.linuxvirtualserver.org/ ) or
17
26
[ HAProxy] ( http://www.haproxy.org/ ) seem to be good choices. On
18
27
PgBouncer side it may be good idea to make ` server_lifetime ` smaller
19
28
and also turn ` server_round_robin ` on - by default idle connections
20
29
are reused by LIFO algorithm which may work not so well when
21
30
load-balancing is needed.
22
31
23
- 2 . DNS round-robin. Use several IPs behind one DNS name. PgBouncer does
24
- not look up DNS each time new connection is launched. Instead it
25
- caches all IPs and does round-robin internally. Note: if there is
26
- more than 8 IPs behind one name, the DNS backend must support EDNS0
27
- protocol. See README for details.
32
+ ## How to failover
33
+
34
+ PgBouncer does not have internal failover-host configuration nor detection.
35
+ It is possible via some external tools:
36
+
37
+ 1 . DNS reconfiguration - when ip behind DNS name is reconfigured, pgbouncer
38
+ will reconnect to new server. This behaviour can be tuned via 2
39
+ config parameters - ** dns_max_ttl** tunes lifetime for one hostname,
40
+ and ** dns_zone_check_period** tunes how often zone SOA will be
41
+ queried for changes. If zone SOA record has changed, pgbouncer
42
+ will re-query all hostnames under that zone.
43
+
44
+ 2 . Write new host to config and let PgBouncer reload it - send SIGHUP
45
+ or use RELOAD; command on console. PgBouncer will detect changed
46
+ host config and reconnect to new server.
28
47
29
48
## How to use SSL connections with PgBouncer?
30
49
50
+ [ TLS support will be in next version of PgBouncer. Build from GIT to get it. ]
51
+
31
52
Use [ Stunnel] ( https://www.stunnel.org/ ) . Since version 4.27 it supports
32
53
PostgreSQL protocol for both client and server side. It is activated by
33
54
setting ` protocol=pgsql ` .
@@ -51,15 +72,7 @@ client.
51
72
### Disabling prepared statements in JDBC
52
73
53
74
The proper way to do it for JDBC is adding ` prepareThreshold=0 `
54
- parameter to connect string. But current JDBC code ignores the setting
55
- for BEGIN/COMMIT/ROLLBACK statements and still tries to cache their
56
- plans. This can be fixed with following patch:
57
-
58
- [ http://treehou.se/~omar/postgresql-jdbc-8.4-701-pgbouncer_txn.patch ] ( http://treehou.se/~omar/postgresql-jdbc-8.4-701-pgbouncer_txn.patch )
59
-
60
- described here:
61
-
62
- [ http://pgfoundry.org/pipermail/pgbouncer-general/2010-February/000507.html ] ( http://pgfoundry.org/pipermail/pgbouncer-general/2010-February/000507.html )
75
+ parameter to connect string.
63
76
64
77
### Disabling prepared statements in PHP/PDO
65
78
0 commit comments