instacart / makara

A Read-Write Proxy for Connections; Also provides an ActiveRecord adapter.
http://tech.taskrabbit.com/
MIT License
928 stars 170 forks source link

Best approach for handling master-slave replication? #319

Open vladimir-stornest opened 3 years ago

vladimir-stornest commented 3 years ago

I'm interested in scaling my Rails application with master-slave replication using Makra.

As I understand, when one of the servers fails, Makara will blacklist it so it won't send traffic to it. But what happens if the master server fails? Then Rails application won't work because it won't be able to do write operations.

I assume I need to install and configure repmgr for automated failover to promote the slave server to master. How will the application know that there is a new master server when the old server will still be hardcoded in the configuration file? Could pgBouncer help with this, and how?

Any feedback is appreciated!

jeremy commented 3 years ago

Check out https://github.com/EnterpriseDB/repmgr/blob/master/doc/repmgrd-node-fencing.md to get started @vladimir-stornest. This is out of scope for Makara. Make backend recovery transparent from its point of view, so all it has to do is try to reconnect.