2

我认为 Couchbase 可能能够解决我当前项目中的很多问题,但我首先需要确定一些基本的事情:

1)假设我有一个有 10 个节点的集群,我向节点 A 添加一个文档。然后我向节点 B 询问该文档,我一定会得到该文档吗?我问节点 B 是否存在风险,它认为该文档不存在?

2)现在说我写了一个视图,以便我可以看到某个作者的所有文档。我将一个文档添加到节点 A。我知道该文档在被索引时出现在视图中存在一定的滞后时间。我想知道的是延迟时间会不会非常小,因为我只索引 1 个文档?

基本上,我有一个网站,可以管理大约 1 亿份文档。任何时候都有成千上万的用户,因此大约有 10 到 20 台服务器在运行。在当前架构下,如果我将文档插入节点 A,当我查找该文档时,我很可能会访问节点 B 来获取它。所以我的总体问题是:

用户将文档插入节点 A,然后我向他们展示所有文档的屏幕。如果我使用的是 Couchbase,则此屏幕将是查询以 Author 为键的视图的结果。用户看不到他们刚刚发布的文档的可能性有多大?

4

2 回答 2

2
  1. You will always be able to get the document back no matter what node you ask. If you use one of the Couchbase SDK's then they will always make sure they ask the node that has the document. If you use moxi then it will do the same so you shouldn't need to worry about this.

  2. This depends on how heavy your write workload is. In the current architecture (2.0) a document must hit disk before it is indexed. If you have a heavy write workload then the lag will increase since there will be a longer line of items that need to be written to disk. I suggest doing benchmarking with your specific application requirements in mind for this use case and posting any problems or issues you have on the Couchbase forums.

Also, you will want to take a look at the commands that have durability requirements and doing queries with the stale query parameter set to false. The durability commands will allow you to have you application block until an item hits disk and doing a query with stale set to false will make sure your view is up to date with the latest items put into Couchbase. This process will ensure your users always see the latest results of you

EDIT: Couchbase 3.0 no longer requires items to be persisted to disk before they can be queried.

于 2013-02-02T20:11:27.873 回答
0

视图更新是一个可调参数。默认情况下,线程每 5 秒唤醒一次,检查更改并在找到时更新索引。调整这些参数或使用 view 参数stale=false进行查询。

从“自动索引更新”下的文档中:

除了可配置的更新间隔,您还可以在后台自动更新所有索引。您可以通过两个参数配置自动更新,更新时间间隔(以秒为单位)和视图引擎更新索引之前发生的文档更改次数。这两个参数是 updateInterval 和 updateMinChanges:

  • updateInterval:时间间隔,以毫秒为单位,默认为 5000 毫秒。在每个 updateInterval 时,视图引擎都会检查磁盘上文档突变的数量是否大于 updateMinChanges。如果为真,则触发视图更新。存储在磁盘上的文档可能会滞后于内存中的文档数十秒。
  • updateMinChanges:重新索引之前发生的文档更改次数,默认为 5000 次更改。

http://docs.couchbase.com/admin/admin/Views/views-operation.html

于 2015-01-20T21:01:34.057 回答