Re: Support load balancing in libpq - Mailing list pgsql-hackers

From Jelte Fennema
Subject Re: Support load balancing in libpq
Date
Msg-id PR3PR83MB0476EC95BA95CE33F952F80AF7B39@PR3PR83MB0476.EURPRD83.prod.outlook.com
Whole thread Raw
In response to Re: Support load balancing in libpq  (Aleksander Alekseev <aleksander@timescale.com>)
Responses Re: Support load balancing in libpq  (Michael Banck <mbanck@gmx.net>)
List pgsql-hackers
I tried to stay in line with the naming of this same option in JDBC and
Npgsql, where it's called "loadBalanceHosts" and "Load Balance Hosts"
respectively. So, actually to be more in line it should be the option for
libpq should be called "load_balance_hosts" (not "loadbalance" like
in the previous patch). I attached a new patch with the name of the
option changed to this.

I also don't think the name is misleading. Randomization of hosts will
automatically result in balancing the load across multiple hosts. This is
assuming more than a single connection is made using the connection
string, either on the same client node or on different client nodes. I think
I think is a fair assumption to make. Also note that this patch does not load
balance queries, it load balances connections. This is because libpq works
at the connection level, not query level, due to session level state.

I agree it is indeed fairly simplistic load balancing. But many dedicated load
balancers often use simplistic load balancing too. Round-robin, random and
hash+modulo based load balancing are all very commonly used load balancer
strategies. Using this patch you should even be able to implement the
weighted load balancing that you suggest, by supplying the same host + port
pair multiple times in the list of hosts.

My preference would be to use load_balance_hosts for the option name.
However, if the name of the option becomes the main point of contention
I would be fine with changing the option to "randomize_hosts". I think
in the end it comes down to what we want the name of the option to reflect:
1. load_balance_hosts reflects what you (want to) achieve by enabling it
2. randomize_hosts reflects how it is achieved


Jelte
Attachment

pgsql-hackers by date:

Previous
From: Michael Paquier
Date:
Subject: Re: New Object Access Type hooks
Next
From: Peter Smith
Date:
Subject: Re: tablesync copy ignores publication actions