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

Is it the right way to load balance couchdb with nginx? #1555

Closed
estellederrien opened this issue Aug 13, 2018 · 1 comment
Closed

Is it the right way to load balance couchdb with nginx? #1555

estellederrien opened this issue Aug 13, 2018 · 1 comment

Comments

@estellederrien
Copy link

So i have this 3 machine couchdb cluster working very well . Each are ubuntu 18.0 versions.

So now, my goal is to add a 4th machine, with NGINX as a load balancer .

I 've edited my following file nginx-config-directory/sites-available/defaut

And have added this :

upstream couchDbCluster {
   server 10.1.0.101:5984; 
   server 10.1.0.102:5984;
   server 10.1.0.103:5984;
}


location /couchdb {
    rewrite /couchdb/(.*) /$1 break;
    proxy_pass http://couchDbCluser;
    proxy_redirect off;
    proxy_buffering off;
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}

Do you think it is the right syntax ?

i wonder if one gentle person could tell me if that is the right way to load balance inside my couchdb ?

What is strange is that i would like to separate when it is a GET or a PUT for example, and this code doesn't seem to care about this . How could i do faster GET queries ?

Do I have to change another file ?

Thanks you a lot for your help, have a nice day !

@wohali
Copy link
Member

wohali commented Aug 13, 2018

Through experience, CouchDB developers recommend using HAProxy as a load balancer. We provide a default configuration that just works™ here: https://github.com/apache/couchdb/blob/master/rel/haproxy.cfg

We do document our recommended Nginx configuration as well. Getting it right is difficult, and there are specific issues with configuring Nginx properly as a reverse proxy for CouchDB when you are using replication, so be sure to review our documentation.

At present, CouchDB does not natively have the concept of "read-only replicas," so there is no need to separate GET and PUT requests.

Finally, remember that in a 2.x CouchDB cluster, additional nodes don't participate in requests for databases you've already created unless you move shards to those new nodes. See the new 2.2.0 documentation on shard management for more details.

@wohali wohali closed this as completed Aug 13, 2018
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