Skip to content
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

多机房部署独立两套leaf服务,会不会生成相同的id? #187

Open
flysnow911 opened this issue Mar 13, 2022 · 4 comments
Open

Comments

@flysnow911
Copy link

生产上用snowflake模式,目前要做部署第二个机房做多活,想在新的机房独立部署一套leaf(两个机房物理位置很远,网络延迟不可控,担心新机房的leaf向老机房的zk注册,及做心跳检测时会出问题), 两套服务同时工作,会不会因为workid相同,生成相同的id?

@ztianz
Copy link

ztianz commented Mar 17, 2022

如果不是同的zk,肯定会有相同的概率。因为不是的zk,workerId有可能是相同的。这是雪花算法的原理造成的。建议还是向同一进行zk注册。

@flwwin
Copy link

flwwin commented Jul 30, 2022

可以加前缀

@lazycece
Copy link

通常不同机房,都应该设置不同workerId,

@zxy1994
Copy link

zxy1994 commented Apr 20, 2023

不同机房(zk也不同)workid可以做偏移啊。我这目前改了下代码,支持配置文件里面配置偏移量;目前机房2的偏移200, 假设机房2的workid从zk上获取到的是1,那么真实使用时用的就是201。考虑到机房1的id服务的最大workid都不会到200, 因此不会有重复问题

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

No branches or pull requests

5 participants