Load balancer
Hi,
Is there any way to achieve load balance on couchbase nodes ?. I am using spymemcached client.
Thanks for the response. sorry mike if i would have not clear in my question.Let me make it clear :
we all know that data is stored on one master(m1) server and replicated to some of the servers(r1,r2);
My requirement is when I enabled replication, is there any way to equally load the master server and replicated servers for any key i.e
get("key1") : 1st time request should fetch value from master
2nd time request should fetch value from replica1
3rd time request should fecth value from replica2
4th time request should fetch value from master
5th time request should fetch value from replica1
6th time request should fecth value from replica2
..
..
nth time from master
n+1 time from replica
i.e i don't want the client always points to master server for any key. client should use both master and replica servers for get and set operations.
I wouldn't recommend this type of behavior. The reason is that master and replica vbuckets are spread equally across the cluster. In Couchbase there is no such thing a node that only contains replica items. As a result if you have a 3 node cluster and do 1000 ops/sec you can expect that each node receives roughly 1000 of ops/sec so your operations should be balanced across the cluster.
Where a scheme like the one you are talking about really helps is when a node that only holds replica data and would just be sitting idle in your cluster. In Couchbase this will never happen. Another reason that replica reads are bad is that you open up the possibility of reading stale data. You might not care about this, but it is something to keep in mind.
With that said we do have a replica read api that I think was just added to the Couchbase 2.0 dp4. This api will allow you to read from a replica node, but I want to point out that the main use case here is for reading from a replica when the master node becomes unavailable eg. just before failover.
Let me know if you have any other questions about this.
[EDIT: replica read should also be part of 1.8.2]
Couchbase Sever uses consistent hashing to make sure that data is spread equally through out all nodes in the cluster. Check out the couchbase java client which is based off of Spymemcached.
http://www.couchbase.com/develop/java/current