CouchDB - SPLessons

CouchDB Load Balancing

Home > Lesson > Chapter 17
SPLessons 5 Steps, 3 Clicks
5 Steps - 3 Clicks

CouchDB Load Balancing

CouchDB Load Balancing

shape Description

The Load balancing permits one to disperse the work tasks equitably over numerous CouchDB nodes. Considering CouchDB utilises a HTTP API, basic HTTP load adjusting programming or equipment can be utilised.Including an elementary burden of balance, all the nodes in the CouchDB will keep up a complete duplicate of the database concluded at the time of replication. All the records are ultimately composed in each and every node, which is a constraint of this methodology since the maintained compose throughput of the whole framework will be restricted to that of the node that takes place gradual.

shape Conceptual figure

There are numerous heap adjusting programming and equipment choices accessible. A fully exchange of each and every accessible instruments and how to install and configure all the accessible stages where extent. Rather, we will concentrate on the process of initialisation and configuration of the Apache HTTP Server as a heap balancer and by utilizing Ubuntu,these directions ought to be effortlessly versatile for the working frameworks.

Nodes in couchDB

shape Description

By sending a compose solicitations to an expert node with a space name of couch- master.example.com and disseminate read solicitations to all nodes in the machines with area names of couch-a.example.com, couch-b.example.com, and couch-c.example.com. Installing CouchDB on the expert node and on each of the three slave nodes.

shape Examples

By viewing the below example,the concept of arranging a nodes in couchDB can be easily understood. [c] [httpd]; port = 5984 bind_address = <server IP address>; Uncomment next line to trigger basic-auth popup on unauthorized requests; WWW-Authenticate = Basic realm="administrator sudo /etc/init.d/couchdb restart curl -X GET http://couch-master.example.com:5984/ curl -X GET http://couch-a.example.com:5984/ curl -X GET http://couch-b.example.com:5984/ curl -X GET http://couch-c.example.com:5984/ {"couchdb":"Welcome","version":"1.0.1"} curl -X PUT http://couch-master.example.com:5984/api curl -X PUT http://couch-a.example.com:5984/api curl -X PUT http://couch-b.example.com:5984/api curl -X PUT http://couch-c.example.com:5984/api {"ok":true} [/c] Here in the above example all the 3 sub nodes are assigned to the main master node.

Proxy server configuration

shape Description

The Apache HTTP server has a great degree of adaptable and contains numerous components that includes an intermediary server and contains a load balancer. In this activity, generating one of the load balancer on a machine with a space name of couch-proxy.example.com.

shape Examples

By viewing the below example,the concept of configuring a server in couchDB can be easily understood. [c] Header append Vary Accept Header add Set-Cookie "NODE=%{BALANCER_WORKER_ROUTE}e; path=/api" \ env=BALANCER_ROUTE_CHANGED <Proxy balancer://couch-slave> BalancerMember http://couch-a.example.com:5984/api route=couch-a max=4 BalancerMember http://couch-b.example.com:5984/api route=couch-b max=4 BalancerMember http://couch-c.example.com:5984/api route=couch-c max=4 ProxySet stickysession=NODE ProxySet timeout=5 </Proxy> RewriteEngine On RewriteCond %{REQUEST_METHOD} ^(POST|PUT|DELETE|MOVE|COPY)$ RewriteRule ^/api(.*)$ http://couch-master.example.com:5984/api$1 [P] RewriteCond %{REQUEST_METHOD} ^(GET|HEAD|OPTIONS)$ RewriteRule ^/api(.*)$ balancer://couch-slave$1 [P] ProxyPassReverse /api http://couch-master:5984/api ProxyPassReverse /api balancer://couch-slave RewriteEngine On RewriteOptions inherit RewriteCond %{REQUEST_METHOD} ^(POST|PUT|DELETE|MOVE|COPY)$ RewriteRule ^/api(.*)$ http://couch-master.example.com:5984/api$1 [P] RewriteCond %{REQUEST_METHOD} ^(GET|HEAD|OPTIONS)$ RewriteRule ^/api(.*)$ balancer://couch-slave$1 [P] ProxyPassReverse /api http://couch-master:5984/api ProxyPassReverse /api balancer://couch-slave ServerLimit 200 ThreadsPerChild 25 MaxClients 5000 [/c] here in the above example the proxy server has been successfully configured to couchDB.

Summary

shape Key Points

  • CouchDB With Rails Load balancing - Permits numerous couchDB nodes to various disperses.
  • Nodes in couchDB - Contains all the disseminate read solicitations to all the nodes in couchDB.
  • Proxy server configuration - Contains intermediary servers and load balancers.