Skip to content

在 AP 模式(最终一致性)下对接 nacos 数据时,如何保证数据是最新且正确的 #13243

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
gxthrj opened this issue Apr 11, 2025 · 4 comments

Comments

@gxthrj
Copy link

gxthrj commented Apr 11, 2025

Nacos 社区小伙伴们好,我来 Apache APISIX 社区

问题描述

我们业务服务集群较大,业务服务可能会有 1000~ 10000 个实例

目前我们在集成 Nacos 时发现,如果使用 Nacos AP 模式系的 SDK,可能会存在短暂的数据不一致,或者脏覆盖的情况。

现在我们的做法是:

  1. 全量获取 service 注册信息;
  2. 增量 watch service 变化;
  3. 定期全量对比(校对);

请问 Nacos 社区是否有更好的建议。

@KomachiSion
Copy link
Collaborator

AP模式可能存在短暂的数据不一致, 这个是AP协议本身特性决定的。

脏覆盖的情况没有遇到过,您的使用场景是获取之后再给予结果再去发布吗? 按理来说您只发布自身服务的话,也不存在脏覆盖的情况。

@KomachiSion
Copy link
Collaborator

KomachiSion commented Apr 11, 2025

建议描述一下场景, 以及现在的用法方式。

@membphis
Copy link

我补充解释一下。

目前订阅 nacos 数据,最前面两个步骤解释如下:

  1. 全量拉取所有关心的 server 信息。时间示例:假设开始时间是 00 秒,假设结束时间是 02 秒,则总耗时 2 秒。
  2. 增量订阅关心 server 信息。对应时间示例:开始订阅时间 02 秒。

目前遇到的问题:

当第 1 步全量拉取执行完毕后进入步骤 2 增量订阅,会错过 nacos 在 00~02 之间的增量变化。

暂定解决方案:

目前我们认为比较简单的补充方案是定时执行全量获取+更新,比如每 30 分钟定期全量同步。也就是前面提到的步骤 3:
3. 定期全量对比(校对);

我们的问题:

对 nacos AP 模式,是否有其他更好的方式同步数据,能够更优的避免丢失增量 service 数据。

@membphis
Copy link

@KomachiSion 您有空看下我的问题补充,感谢

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants