forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit7f5b198
committed
Support connection load balancing in libpq
This adds support for load balancing connections with libpq using aconnection parameter: load_balance_hosts=<string>. When setting theparam to random, hosts and addresses will be connected to in randomorder. This then results in load balancing across these addresses andhosts when multiple clients or frequent connection setups are used.The randomization employed performs two levels of shuffling: 1. The given hosts are randomly shuffled, before resolving them one-by-one. 2. Once a host its addresses get resolved, the returned addresses are shuffled, before trying to connect to them one-by-one.Author: Jelte Fennema <postgres@jeltef.nl>Reviewed-by: Aleksander Alekseev <aleksander@timescale.com>Reviewed-by: Michael Banck <mbanck@gmx.net>Reviewed-by: Andrey Borodin <amborodin86@gmail.com>Discussion:https://postgr.es/m/PR3PR83MB04768E2FF04818EEB2179949F7A69@PR3PR83MB0476.EURPRD83.prod.outlook.1 parent44d85ba commit7f5b198
File tree
10 files changed
+431
-3
lines changed- doc/src/sgml
- src
- interfaces/libpq
- t
- test/perl/PostgreSQL/Test
- tools/pgindent
10 files changed
+431
-3
lines changedLines changed: 15 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
25 | 25 |
| |
26 | 26 |
| |
27 | 27 |
| |
28 |
| - | |
| 28 | + | |
29 | 29 |
| |
30 | 30 |
| |
31 | 31 |
| |
| |||
313 | 313 |
| |
314 | 314 |
| |
315 | 315 |
| |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
316 | 324 |
| |
317 | 325 |
| |
318 | 326 |
| |
| |||
564 | 572 |
| |
565 | 573 |
| |
566 | 574 |
| |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
567 | 581 |
| |
568 | 582 |
| |
569 | 583 |
| |
|
Lines changed: 61 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2115 | 2115 |
| |
2116 | 2116 |
| |
2117 | 2117 |
| |
| 2118 | + | |
| 2119 | + | |
| 2120 | + | |
| 2121 | + | |
| 2122 | + | |
| 2123 | + | |
| 2124 | + | |
| 2125 | + | |
| 2126 | + | |
| 2127 | + | |
| 2128 | + | |
| 2129 | + | |
| 2130 | + | |
| 2131 | + | |
| 2132 | + | |
| 2133 | + | |
| 2134 | + | |
| 2135 | + | |
| 2136 | + | |
| 2137 | + | |
| 2138 | + | |
| 2139 | + | |
| 2140 | + | |
| 2141 | + | |
| 2142 | + | |
| 2143 | + | |
| 2144 | + | |
| 2145 | + | |
| 2146 | + | |
| 2147 | + | |
| 2148 | + | |
| 2149 | + | |
| 2150 | + | |
| 2151 | + | |
| 2152 | + | |
| 2153 | + | |
| 2154 | + | |
| 2155 | + | |
| 2156 | + | |
| 2157 | + | |
| 2158 | + | |
| 2159 | + | |
| 2160 | + | |
| 2161 | + | |
| 2162 | + | |
| 2163 | + | |
| 2164 | + | |
| 2165 | + | |
| 2166 | + | |
| 2167 | + | |
| 2168 | + | |
| 2169 | + | |
| 2170 | + | |
| 2171 | + | |
| 2172 | + | |
| 2173 | + | |
| 2174 | + | |
| 2175 | + | |
| 2176 | + | |
| 2177 | + | |
| 2178 | + | |
2118 | 2179 |
| |
2119 | 2180 |
| |
2120 | 2181 |
| |
|
Lines changed: 12 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
256 | 256 |
| |
257 | 257 |
| |
258 | 258 |
| |
259 |
| - | |
| 259 | + | |
260 | 260 |
| |
261 | 261 |
| |
262 | 262 |
| |
| |||
290 | 290 |
| |
291 | 291 |
| |
292 | 292 |
| |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
293 | 304 |
| |
294 | 305 |
| |
295 | 306 |
| |
|
Lines changed: 103 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
123 | 123 |
| |
124 | 124 |
| |
125 | 125 |
| |
| 126 | + | |
126 | 127 |
| |
127 | 128 |
| |
128 | 129 |
| |
| |||
351 | 352 |
| |
352 | 353 |
| |
353 | 354 |
| |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
354 | 360 |
| |
355 | 361 |
| |
356 | 362 |
| |
| |||
435 | 441 |
| |
436 | 442 |
| |
437 | 443 |
| |
| 444 | + | |
| 445 | + | |
438 | 446 |
| |
439 | 447 |
| |
440 | 448 |
| |
| |||
1020 | 1028 |
| |
1021 | 1029 |
| |
1022 | 1030 |
| |
| 1031 | + | |
| 1032 | + | |
| 1033 | + | |
| 1034 | + | |
| 1035 | + | |
| 1036 | + | |
| 1037 | + | |
| 1038 | + | |
| 1039 | + | |
| 1040 | + | |
| 1041 | + | |
| 1042 | + | |
| 1043 | + | |
| 1044 | + | |
| 1045 | + | |
| 1046 | + | |
| 1047 | + | |
| 1048 | + | |
| 1049 | + | |
| 1050 | + | |
| 1051 | + | |
| 1052 | + | |
| 1053 | + | |
| 1054 | + | |
| 1055 | + | |
1023 | 1056 |
| |
1024 | 1057 |
| |
1025 | 1058 |
| |
| |||
1619 | 1652 |
| |
1620 | 1653 |
| |
1621 | 1654 |
| |
| 1655 | + | |
| 1656 | + | |
| 1657 | + | |
| 1658 | + | |
| 1659 | + | |
| 1660 | + | |
| 1661 | + | |
| 1662 | + | |
| 1663 | + | |
| 1664 | + | |
| 1665 | + | |
| 1666 | + | |
| 1667 | + | |
| 1668 | + | |
| 1669 | + | |
| 1670 | + | |
| 1671 | + | |
| 1672 | + | |
| 1673 | + | |
| 1674 | + | |
| 1675 | + | |
| 1676 | + | |
| 1677 | + | |
| 1678 | + | |
| 1679 | + | |
| 1680 | + | |
| 1681 | + | |
| 1682 | + | |
| 1683 | + | |
| 1684 | + | |
| 1685 | + | |
| 1686 | + | |
| 1687 | + | |
| 1688 | + | |
| 1689 | + | |
| 1690 | + | |
| 1691 | + | |
| 1692 | + | |
| 1693 | + | |
| 1694 | + | |
| 1695 | + | |
| 1696 | + | |
| 1697 | + | |
1622 | 1698 |
| |
1623 | 1699 |
| |
1624 | 1700 |
| |
| |||
2626 | 2702 |
| |
2627 | 2703 |
| |
2628 | 2704 |
| |
| 2705 | + | |
| 2706 | + | |
| 2707 | + | |
| 2708 | + | |
| 2709 | + | |
| 2710 | + | |
| 2711 | + | |
| 2712 | + | |
| 2713 | + | |
| 2714 | + | |
| 2715 | + | |
| 2716 | + | |
| 2717 | + | |
| 2718 | + | |
| 2719 | + | |
| 2720 | + | |
| 2721 | + | |
| 2722 | + | |
| 2723 | + | |
| 2724 | + | |
| 2725 | + | |
| 2726 | + | |
| 2727 | + | |
| 2728 | + | |
| 2729 | + | |
| 2730 | + | |
2629 | 2731 |
| |
2630 | 2732 |
| |
2631 | 2733 |
| |
| |||
4320 | 4422 |
| |
4321 | 4423 |
| |
4322 | 4424 |
| |
| 4425 | + | |
4323 | 4426 |
| |
4324 | 4427 |
| |
4325 | 4428 |
| |
|
Lines changed: 16 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
26 | 26 |
| |
27 | 27 |
| |
28 | 28 |
| |
29 |
| - | |
| 29 | + | |
| 30 | + | |
30 | 31 |
| |
31 | 32 |
| |
32 | 33 |
| |
| |||
82 | 83 |
| |
83 | 84 |
| |
84 | 85 |
| |
| 86 | + | |
| 87 | + | |
85 | 88 |
| |
86 | 89 |
| |
87 | 90 |
| |
| |||
242 | 245 |
| |
243 | 246 |
| |
244 | 247 |
| |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
245 | 255 |
| |
246 | 256 |
| |
247 | 257 |
| |
| |||
398 | 408 |
| |
399 | 409 |
| |
400 | 410 |
| |
| 411 | + | |
401 | 412 |
| |
402 | 413 |
| |
403 | 414 |
| |
| |||
469 | 480 |
| |
470 | 481 |
| |
471 | 482 |
| |
| 483 | + | |
| 484 | + | |
472 | 485 |
| |
473 | 486 |
| |
474 | 487 |
| |
| |||
488 | 501 |
| |
489 | 502 |
| |
490 | 503 |
| |
| 504 | + | |
| 505 | + | |
491 | 506 |
| |
492 | 507 |
| |
493 | 508 |
| |
|
Lines changed: 2 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
116 | 116 |
| |
117 | 117 |
| |
118 | 118 |
| |
| 119 | + | |
| 120 | + | |
119 | 121 |
| |
120 | 122 |
| |
121 | 123 |
| |
|
0 commit comments
Comments
(0)