-
Notifications
You must be signed in to change notification settings - Fork 446
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
Allow clients to connect to standby replicas in RO mode #132
Comments
@inean Also if the proxy was born with the primary needs to forcibly close connections to old master (I tried to explain it in the FAQ) I think that this can be a good idea (though about it but waiting for someone needing it before implementing 😄). I'm thinking to just add a Some question:
|
the
yes, IMHO client connections should be closed. In that case client apps react to those broken connections and try to acquire new RO ones from proxy. It's consistent with the procedure for RW connections.
Yes, another option maybe to use a (Weighter) Least Connection scheduler; your solution uses etcd/consul so we can store usage count there. Said that, we need to handle the case of a new standby added to cluster. Typically, client apps maintain a pool of connections to DB, in this case to One possible solution is that |
I would like to describe a workaround that could be used before v0.4.0 release. Currently application can learn cluster configuration from |
@sgotti can we expect this to land in |
Hi, I would like to add a note regarding PostgreSQL 10. libpq was extended to handle new attribute in the connection string called "target_session_attrs" (http://paquier.xyz/postgresql-2/postgres-10-libpq-read-write/). |
Also related to #489. My final thoughts are to avoid reinventing the wheel and modifyng stolon proxy:
So, instead of reinventing a load balancer and putting it inside stolon proxy my current idea (that someone already probably does with some custom scripts) is to make people able to use something already existing like haproxy to load balance to active standbys. For example we could add a command (to stolonctl or a new one) that will populate a template haproxy conf retrieving the current active standbys from the stolon clusterdata and execute a reload when the this standby list changes. Something similar to how confd or consul-template works. If someone is willing to do this work I'll happily review their PRs. |
I created the simple python script that talks with stolonctl and generates an HAProxy config for standby replicas. Hope it may be useful. |
Just linking to a description of pgpool's load-balancing solution: |
@strangeman Your solution implements what I meant. Congrats! I'd like to link it from the from the FAQ. Would you like to open a PR? |
@liqweed The proxy is just a layer4 proxy and doesn't speak the postgres protocol: #39 (comment) . Pgpool is a totally different project with totally different features and can be used on top of stolon if needed. A good implementation of this feature request is the @strangeman project reported before your comment: #132 (comment) |
Based on @strangeman script, if you want to try the setup on Mac, https://gist.github.com/viggy28/e3de61a2070f6171c966b16dc36a1d32 |
Sometimes apps maintains a 2 pool of connections; one for master node for writing purposes only and another one for replicas for 'read' operations. It would be good if proxies allow somehow to do that
The text was updated successfully, but these errors were encountered: