如何从 documentdb 集群的特定实例读取
我遇到了 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.
So, is it possible to read from the primary instance in nodejs or is it possible to read from a specific instance?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
复制滞后有多大?可能值得调查延迟的原因,也许需要更大的实例或必须优化查询。
如果您的应用程序不能容忍最终一致性或需要写入一致性后读取,则使用 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:
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.