-
Notifications
You must be signed in to change notification settings - Fork 46
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 to have a master/replica DB configuration #2223
Conversation
The session is bound to a request, so binding the connection would work (like you say, assuming that no writes are done in GET requests). You are proposing to use a DNS to support multiple read-only instances. We could also allow to specify multiple read-only connections and then use a simple random load-balancing strategy to avoid the name-resolution step. Maybe you want to add some documentation on how to configure the actual replication in Postgres? And on a side node: It would be great if we could avoid a historically racially charged term and maybe use "primary - replica/read-only" instead (for example like Drupal or CouchDB). |
@tsauerwein, slavery is not necessarily linked to races. Romans were enslaving their own, sometimes. But OK, I'm removing references to our dark past (and present) and I'm using Postgres' other terms: master/replica. And added a link to their doc for how to set it up. Regarding the DNS or multiple addresses, after discussion with our IT experts, it's not enough. If you want failover, you need to setup two HAProxy:
I've added that to the doc, but without much details. It's out of my league/responsibilities ;-) |
@fredj, I've heard you've worked on that problem in the past. Any opinion? |
Thanks! 👍 |
We created 2 distinct engines (one for reads and one for writes) and we used one or the other depending on the operation. |
I don't found the therm replica relay useful, every body know whats a master-slave architecture is and we don't do philosophy... |
Basically, this guy switches the DB connection to a replica (readonly) DB if the HTTP method is GET or OPTIONS.
Here is an example of a GET request that also writes to the database: c2cgeoportal/c2cgeoportal/views/shortener.py Lines 55 to 64 in 9425952
|
@tsauerwein, you should look at the last version of my patch. I've added the possibility to force the usage of the master or the replica for some URLs. And the shortener is part of it. |
Perfect, I missed that. |
So... what now? Merge or not? |
LGTM |
Basically, this guy switches the DB connection to a replica (readonly) DB if the HTTP method is GET or OPTIONS.