Skip to content
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

haproxy: enable direct connections apart from pgbouncer ones (#548) #549

Merged
merged 9 commits into from
Jan 15, 2024

Conversation

jimnydev
Copy link
Contributor

This is a tackle at #548

It's a draft, just to double check with you if you'd go this way (say, variable names).
I'm not sure if we should provide a direct connections to individual replicas (so I've just provided a generic one, initially).

Also, HAProxy config is added at the end of existing stuff. I can split it so that master and replicas are grouped within existing previous sections (although it would duplicate the check if it should be included).

Thanks!

@vitabaks vitabaks marked this pull request as ready for review January 10, 2024 11:45
vars/main.yml Outdated Show resolved Hide resolved
@vitabaks
Copy link
Owner

Test

listen master
    bind 10.172.0.20:5000
    maxconn 10000
    option tcplog
    option httpchk OPTIONS /primary
    http-check expect status 200
    default-server inter 3s fastinter 1s fall 3 rise 4 on-marked-down shutdown-sessions
 server pgnode01 10.172.0.20:6432 check port 8008
 server pgnode02 10.172.0.21:6432 check port 8008
 server pgnode03 10.172.0.22:6432 check port 8008

listen master_direct
    bind 10.172.0.20:6000
    maxconn 10000
    option tcplog
    option httpchk OPTIONS /primary
    http-check expect status 200
    default-server inter 3s fastinter 1s fall 3 rise 4 on-marked-down shutdown-sessions
 server pgnode01 10.172.0.20:5432 check port 8008
 server pgnode02 10.172.0.21:5432 check port 8008
 server pgnode03 10.172.0.22:5432 check port 8008

listen replicas
    bind 10.172.0.20:5001
    maxconn 10000
    option tcplog
    option httpchk OPTIONS /replica
    balance roundrobin
    http-check expect status 200
    default-server inter 3s fastinter 1s fall 3 rise 2 on-marked-down shutdown-sessions
 server pgnode01 10.172.0.20:6432 check port 8008
 server pgnode02 10.172.0.21:6432 check port 8008
 server pgnode03 10.172.0.22:6432 check port 8008

listen replicas_direct
    bind 10.172.0.20:6001
    maxconn 10000
    option tcplog
    option httpchk OPTIONS /replica
    balance roundrobin
    http-check expect status 200
    default-server inter 3s fastinter 1s fall 3 rise 2 on-marked-down shutdown-sessions
 server pgnode01 10.172.0.20:5432 check port 8008
 server pgnode02 10.172.0.21:5432 check port 8008
 server pgnode03 10.172.0.22:5432 check port 8008
root@pgnode01:/# systemctl stop pgbouncer
root@pgnode01:/# systemctl stop pgbouncer-2
root@pgnode01:/# psql -h 10.172.0.20 -p 5000 -U postgres
^C
root@pgnode01:/# psql -h 10.172.0.20 -p 6000 -U postgres
Password for user postgres: 
psql (16.1 (Ubuntu 16.1-1.pgdg22.04+1))
SSL connection (protocol: TLSv1.3, cipher: TLS_AES_256_GCM_SHA384, compression: off)
Type "help" for help.

postgres=# \q
root@pgnode01:/# psql -h 10.172.0.20 -p 6001 -U postgres
Password for user postgres: 
psql (16.1 (Ubuntu 16.1-1.pgdg22.04+1))
SSL connection (protocol: TLSv1.3, cipher: TLS_AES_256_GCM_SHA384, compression: off)
Type "help" for help.

postgres=# \q

passed

@vitabaks vitabaks merged commit 166ddae into vitabaks:master Jan 15, 2024
17 checks passed
@jimnydev jimnydev deleted the direct_connection branch July 8, 2024 20:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants