-
-
Notifications
You must be signed in to change notification settings - Fork 389
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How can haproxy manage load balancing in case of primary goes down. #680
Comments
HAProxy checks the role of each server through the Patroni REST API, so it does not matter which balancing the connection is made through, since each haproxy will know about the current cluster topology. |
to ensure connection pooling and load balancing without write queries going to read replicas , how should I proceed ? For connection pooling , I use below query : psql -p 15432 (pgbouncer port) and for haproxy : psql -p 25432 (haproxy port) :: question : is this connection using connection pooling as well as explained in the above image and is it going to only master ? I am getting " update cannot be done in read-only transaction" error . |
yes, if
Perhaps your application maintains a permanent connection to the database and HAProxy does not break these connections when changing the Postgres role. Example:
callbacks:
on_role_change: '/etc/patroni/haproxy_restart.sh'
#!/bin/bash
# /etc/patroni/haproxy_restart.sh
# restart haproxy on all servers in the cluster
for host in $(patronictl -c /etc/patroni/patroni.yml list -f json | jq -r '.[] | .Host'); do
ssh \
-o StrictHostKeyChecking=no \
-o UserKnownHostsFile=/dev/null \
postgres@"${host}" \
sudo systemctl restart haproxy
done |
How can we ensure in case of primary goes down and vip still points to the same server that my write operation always goes to primary server without failure.
If it is not possible can we have pgpool in this setup?
The text was updated successfully, but these errors were encountered: