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

Support set threshold of the same AZ instance survival ratio to allow across AZ invoke in the AZ affinity scenario #1393

Open
chengyouling opened this issue Oct 24, 2024 · 0 comments
Assignees

Comments

@chengyouling
Copy link
Collaborator

chengyouling commented Oct 24, 2024

在使用AZ亲和场景中,同AZ与其他AZ的实例数都比较多时,亲和选择实例逻辑调整为根据设置的最小、最大占比来返回不同实例。

当前逻辑:
1、优先返回同AZ的实例;
2、如果同AZ实例不存在,返回同region不同AZ的实例;
3、如果当前region不存在可用实例,通过开关denyCrossZoneLoadBalancing确认是否返回所有实例,默认为false返回全部实例。

预调整逻辑:
1、设置区、域的亲和实例比例下限,默认值30(百分值),比例上限,默认值为100-比例值;
2、首先判断同AZ实例在所有获取的实例中占比是否在下限至上限之间,如果在直接返回同AZ实例;
3、如果通AZ实例不满足区间值,加入同region的存活实例,如果同AZ+同region实例数在区间内,反回同AZ+同region实例;
4、如果同AZ+同region实例不再区间内,返回所有实例。

例如:
region1的两个AZ1、AZ2区均部署serviceA、serviceB服务各10个实例,region2的AZ3区部署serviceA、serviceB服务各5个实例,serviceA调用serviceB,serviceA能够发现region1-AZ2及region2-AZ3的serviceB实例

1、当AZ1区的serviceB存活实例为5,AZ2区域存活实例为5,AZ3区域存活实例为5,那么AZ1的serviceA通过服务发现得到同AZ的serviceB占比为33%,那么将返回AZ1的5个serviceB实例供A调用。

2、当AZ1区的serviceB存活实例为2,AZ2区域存活实例为5,AZ3区域存活实例为5,那么AZ1的serviceA通过服务发现得到同AZ的serviceB占比为17%,AZ1+AZ2实例占比58%,那么将返回AZ1+AZ2的7个serviceB实例供A调用。

3、当AZ1区的serviceB存活实例为1,AZ2区域存活实例为1,AZ3区域存活实例为5,那么AZ1的serviceA通过服务发现得到同AZ的serviceB占比为14%,AZ1+AZ2实例占比29%,都在设置下限30以下,那么将返回所有的serviceB实例供A调用。

4、当AZ1区的serviceB存活实例为5,AZ2区域存活实例为1,AZ3区域存活实例为1,那么AZ1的serviceA通过服务发现得到同AZ的serviceB占比为71%,AZ1+AZ2实例占比86%,都在设置上限70以上,那么将返回所有的serviceB实例供A调用。

@chengyouling chengyouling changed the title Support set threshold of the instance survival ratio in same AZ that allow across AZ invoke in the AZ affinity scenario Support set threshold of the same AZ instance survival ratio to allow across AZ invoke in the AZ affinity scenario Oct 24, 2024
@chengyouling chengyouling self-assigned this Oct 24, 2024
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

1 participant