如何从 documentdb 集群的特定实例读取

发布于 2025-01-10 16:50:47 字数 306 浏览 0 评论 0原文

我遇到了 documentDB 的副本滞后问题。我试图从集合中写入一些数据并同时读取相同的数据。但是因为我使用的是分布式系统,所以我无法从副本集中读取已写入的数据。

这是集群设计。

输入图片此处描述

那么,是否可以从nodejs中的主实例读取,或者是否可以从特定实例读取?

I am having a replica lag issue with documentDB. Where I am trying to write some data from a collection and read the same at the same time. But because I am using a distributed system, I am not able to read the already written data from the replica sets.

Here's the cluster design.

enter image description here.

So, is it possible to read from the primary instance in nodejs or is it possible to read from a specific instance?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

枯寂 2025-01-17 16:50:47

复制滞后有多大?可能值得调查延迟的原因,也许需要更大的实例或必须优化查询。
如果您的应用程序不能容忍最终一致性或需要写入一致性后读取,则使用 readPreference:primaryPreferred 指示驱动程序在可用时从主实例读取。但是,在这种情况下,副本将不会用于水平扩展读取流量。

Amazon DocumentDB 也有其他终端节点:

最佳实践是作为副本集进行连接,使用 readPreference 参数来调整首选项。例如,当需要大型分析查询并且临时部署更大的实例来运行它们时,实例端点可能会很有用。

How big is the replication lag? It might be worth investigating the cause for the lag, maybe bigger instances are needed or queries have to be optimized.
If your application can't tolerate eventual consistency or read after write consistency is required, then use readPreference: primaryPreferred to instruct the driver to read from the Primary instance when available. However, in this case, the replicas will not be used to scale horizontally the read traffic.

Amazon DocumentDB has other endpoints too:

  • reader endpoint - points to replica instances, it's found in the configuration section of the cluster (console or aws cli describe-db-clusters command)
  • instance endpoint - each instance has its own endpoint, it's found in the instances section (console or aws cli describe-db-instances command)

The best practice is to connect as replica set, using the readPreference parameter to adjust the preference. Instance endpoints can be useful when, for example, there's a need for large analytics queries and a bigger instance is deployed, temporarily, to run them.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文