Just looking for info on what strategies people use for this?
In the examples I see it is really easy to make a remote database connection that I will call get()
on.
var remoteDb = new PouchDB('https://myhost.com/db');
var data = remoteDb.get("myId");
But what if I have several remote databases set up that are syncing with each other. I want the clients to be able to use them all without changing the code.
I am considering doing this through dns. For example have db.myhost.com with multiple records pointing to the other servers. If I do this and one server goes down will pouchDB realize and reconnect to another?
Potentially I could write some javascript to give users a random server or assign a server based on region, etc. Then I could set up error handlers to switch servers on any errors. Is this necessary or is it already implemented in some library I could use?
You can use nginx as a reverse proxy for that, as explained here: http://karmi.tumblr.com/post/247255194/simple-couchdb-multi-master-clustering-via-nginx
Basically you configure nginx to listen on one address and then pass the traffic to your CouchDB instances (adapted from the original post):