Can we use commercial load balancer in Postgres HA

We have setup an environment of Postgres 15 cluster thru etcd and patroni with the help of HAProxy. Can we use any commercial load balancer in place of HAproxy ? Like F5 or Fortigate

1 Like

HAProxy can be replaced with the F5. Both are dumb layer 4 routers.

1 Like

Do you have any PostgresSQL specific article ? Usually any load balancer also do a round robin traffic distribution of traffic towards nodes which is not is the case of Postgres HA, Actually the HAproxy connects with Patroni thru API on port 8008 to validate the health of node. is it possible that you may share something specific to Postgres ?

1 Like

Hi,

You have a good question that can go in several directions depending upon the answer you want.

In regards to pure load balancing; the obvious difference between HAProxy and an appliance, like F5, is that one is software and the other is hardware i.e. one solution is open-source while the other is proprietary. Each solution has their strengths but it really depends on your priorities. Apologies if this sounds vague but it’s hard to answer without knowing more about your requirements.

Another consideration when load balancing an HA PostgreSQL cluster is when the client application must find the PRIMARY after a failover. This is especially true when a cluster managing solution, like Patroni, can change the configuration with little warning. In this instance I’d like to suggest you review the Parameter Key Words section of the postgres reference documentation and look up target_session_attrs. This conninfo attribute permits the client to connect to the server of its choice depending on the type of host.

I hope this helps.

1 Like