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

Support libpq compatible load_balance_hosts parameter #2059

Open
piraz opened this issue Jun 24, 2024 · 4 comments
Open

Support libpq compatible load_balance_hosts parameter #2059

piraz opened this issue Jun 24, 2024 · 4 comments

Comments

@piraz
Copy link

piraz commented Jun 24, 2024

Hello @jackc,

I understand that we can use multiple hosts as described in the question #1184. This is supported by client applications relying on plbpq since PostgreSQL 10.

Do pgx suport/has a similar option as libpq to perform random load balance at client level added to PostgreSQL 16?

The new feature was added to be complaint with the existing JDBC implementation, introducing a new parameter to the connection string called load_balance_hosts, and new env variable PGLOADBALANCEHOST.

The option load_balance_hosts has two options, Disable where libpq will attempt to establish a connection using the host list provided(in order), with no load balancing, and Random providing attempt to connect to a randomly selected host from the list.

Do we have an option like that available currently in the project?

Thank you very much.

See:

@jackc
Copy link
Owner

jackc commented Jun 24, 2024

Do we have an option like that available currently in the project?

No, there is not.

@piraz
Copy link
Author

piraz commented Jun 25, 2024

Do you think this is a relevant feature to be added to the project?

If yes, should I come with a new ticket or we just set this one a feature request?

@jackc
Copy link
Owner

jackc commented Jun 25, 2024

Do you think this is a relevant feature to be added to the project?

I think it is a reasonable feature. But it might be a bit tricky to do.

pgx uses FallbackConfigsto represent all connection attempts that may be made. Ansslmodesuch aspreferas represented as 2 connection attempts that may be made. A host that resolves to multiple IPs is represented as multipleFallbackConfigs. And when multiple hosts are specified they are represented as FallbackConfigs. Exactly matching libpq's behavior may be challenging. The simple approach of shuffling the FallbackConfigs would break sslmode prefer`.

Not really sure what a good approach would be.

If yes, should I come with a new ticket or we just set this one a feature request?

Let's use this issue.

@jackc jackc changed the title Do pgx suport/has a similar option as libpq to perform random load balance at client level? Support libpq compatible load_balance_hosts parameter Jun 25, 2024
@piraz
Copy link
Author

piraz commented Jun 25, 2024

Thank you very much.

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

No branches or pull requests

2 participants