Couchbase Server related Queries

Hi All,

I’ve following queries regarding Couchbase:

  1. If we use Couchbase cluster then same data is written in all nodes (as active and replica). If we have 4 nodes then can we configure the cluster to keep the active data in one node and replica in another node (just 1 instead of all 3)?
  2. Can we use custom authentication for any data storage related operation on Couchbase? If we want to store data on couchbase we will pass a token along with the API request. Is it possible to validation that passed token through another external API call? I think Couch Mobile has a feature like this.

I tried to search on google but unfortunately couldn’t find any answer anywhere. Any help is much appreciated.

No, your data is split (“shared”) into 1024 chunks or vBuckets, and then each vBucket has a single active location, and then 0…N _replica copies on a different node.

Dustin’s original blog post on the topic is a nice overview.

To your question - the number of extra copies (replicas) is controlled by how many replicas you configure when you create a Bucket - so just select 1 replica.

Thanks a lot for confirming that. What I understood is:

I have a cluster of 4 nodes. If I have 1 bucket configured to create 1 replica then following will happen:
If I have 100 documents within the bucket then the active data (documents) can be in any of those 4 nodes. May be node1 may have 10 active documents, node 2 may have 30, node 3 may have 20 and node 4 may have 40. But the replica data will be stored in only 1 node. Is my understanding correct?

How can we check where the active data and the replica data lies?

P.S. Any idea about my second question?

Couchbase Server is expected to be within your firewall[quote=“asif.kamal, post:3, topic:10637”]
I have a cluster of 4 nodes. If I have 1 bucket configured to create 1 replica then following will happen:
If I have 100 documents within the bucket then the active data (documents) can be in any of those 4 nodes. May be node1 may have 10 active documents, node 2 may have 30, node 3 may have 20 and node 4 may have 40. But the replica data will be stored in only 1 node. Is my understanding correct?
[/quote]

Yes - and for each document the replica will be on a different node to the active data.

You shouldn’t really need to care (that’s the whole point of the auto-sharding), but you can use the cbc hash command (part of the C SDK tools) to see which vBucket number a key hashes to, and from that you can see which node has a given vBucket.

Thanks a ton again ! :slight_smile:

Does this imply that I won’t be able to authenticate the request using my own API? I’m planning to host the cluster on the cloud. So while syncing CouchBase cluster with PouchDB or performing write/read operation on the Couchbase I was planning to pass an authentication token which was expected to be verified by my own API. The sync operation or the crud operation might be initialized from so many devices so the authentication part is required.

No, you can create whatever API you want, but Couchbase Server currently only exposes a single username/password per bucket. Therefore any additional authentication will have to be added by yourself in your App Server tier.