1

When I query a view from a Couchbase cluster, will each machine return the same result for the view query?

I would expect the cluster to return the same response regardless of which machine actually responds to the request.

theMayer
  • 15,456
  • 7
  • 58
  • 90
doron aviguy
  • 2,554
  • 2
  • 22
  • 18
  • http://www.couchbase.com/wiki/display/couchbase/Couchbase+View+Engine+Internals , ( eache machien will return the same reuslt as i understand it ) – doron aviguy Oct 22 '14 at 10:19

2 Answers2

1

How critically does your application depend upon consistent view results? Remember that Couchbase indices are eventually consistent, meaning that the clusters will not be updated all at the same time, especially when there is a high volume of data changes. So, for data that has been around for a while, you could expect consistent result sets between machines; however, data that has very recently changed may not be reflected in the latest view query. The key is to design your application to deal with this case.

theMayer
  • 15,456
  • 7
  • 58
  • 90
  • Thanks ,i did some more reading about that issue , and views are good for my use case. the link i have posted realy clears things up and the use of "stale" param is important – doron aviguy Oct 23 '14 at 13:03
  • Just to be clear, Couchbase itself is strongly consistent, but the views are eventually consistent. That is a very key difference – NoSQLKnowHow Oct 23 '14 at 15:15
  • In addition, there's another little gotcha here: Couchbase views only work on data that has been persisted to disc (as opposed to RAM). from the doc: "Documents are included in views when the document data is persisted to disk. " Some clients can ensure that your 'set's persist data to disc - you might want to use that feature. In python, for example, refer to the 'persist_to' flag. – FuzzyAmi Aug 04 '15 at 05:58
0

The storage of Couchbase views is spread across the cluster nodes, just like the data is. For example on a three node cluster and with one view, 1/3 of the view would be on each node of the cluster. The part of the view on each cluster is the part that corresponds to the data in the vBuckets on that node. So when you query a Couchbase view, it goes to each node to work on that query. This is all transparent to you as you are using the SDK, but that is what is happening in the background. When a rebalance happens, the views change too since the vBuckets are moving. By default IndexAwareRebalances are set to true.

You also have to realize how often views are updated. By default, it is every 5 seconds AND if there are 5000 data mutations. Not or. These defaults can be tuned, but if for example you only have 1000 mutations, the indexer will not run on its own. Be careful with that stale=false thing too. It can get you into real trouble using it all of the time, especially during rebalances.

Also, know that Couchbase is strongly consistent, but views are eventually consistent.

NoSQLKnowHow
  • 4,449
  • 23
  • 35