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

java中workerId的数据类型short最大值是32767,要是服务集群部署,每个节点分配一个用不了多久就达到最大值了吧 #83

Open
gulang12 opened this issue Nov 10, 2023 · 3 comments

Comments

@gulang12
Copy link

项目中使用redis自增的方式为微服务集群每个节点动态分配workerId值,就是每次服务启动的时候采用redis从0开始自增获取workerId,
要是集群规模比较大的话,用不了多久这个workerId就能达到short最大值了吧,难道要重新把它刷到0开始自增吗

@yitter
Copy link
Owner

yitter commented Nov 11, 2023

@yitter
Copy link
Owner

yitter commented Dec 11, 2023

你的服务器集群,容器启动个数,会超过32700个吗?

@irwinai
Copy link

irwinai commented Feb 2, 2024

你的服务器集群,容器启动个数,会超过32700个吗?

当然会了,我们现在就是扩位的,16位,用IP最后两位,最大长度是2^16-1,short在这里不合理,对于java来说,java都是有符号位的。

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

3 participants