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

Slot Chain 加载顺序问题导致网关限流规则不生效 order of the slot chain builder confusing #1306

Closed
stelin opened this issue Feb 26, 2020 · 10 comments
Labels
area/gateway-flow-control Issues or PRs related to API gateway flow control

Comments

@stelin
Copy link

stelin commented Feb 26, 2020

Issue Description

Type: bug report or feature request

Describe what happened (or what feature you want)

spring cloud 2.2.0 对接 sentinel 1.7.1,限流功能无效

Describe what you expected to happen

spring cloud 2.2.0 对接 sentinel 1.7.1,能正常限制请求流量

How to reproduce it (as minimally and precisely as possible)

Tell us your environment

Anything else we need to know?

@stelin
Copy link
Author

stelin commented Feb 26, 2020

for (T instance : serviceLoader) {
                if (instance.getClass() != defaultClass) {
                    return instance;
                }
            }

查了下好像是这里没有始化网关的

@cdfive cdfive added the area/gateway-flow-control Issues or PRs related to API gateway flow control label Feb 26, 2020
@cdfive
Copy link
Collaborator

cdfive commented Feb 26, 2020

Sentinel网关限流规则会转换为热点规则,看上去是依赖项少了。
检查下项目的依赖项里是否有sentinel-parameter-flow-control模块。

如果使用SCA的spring-cloud-alibaba-sentinel-gateway,因为它同时集成了zuul和spring cloud gateway,这两个依赖是可选的(optional),需要使用方显示地加上依赖。如使用spring cloud gateway,加上依赖spring-cloud-starter-gateway

@sczyh30
Copy link
Member

sczyh30 commented Feb 26, 2020

具体加载到了哪个 slot chain?贴一下所有引的 Spring Cloud Alibaba 和 Sentinel 相关的依赖。

@stelin
Copy link
Author

stelin commented Feb 26, 2020

已经定位问题,临时接了下,问题是SPI加多个载顺序问题,钉钉上面详细回复了

@chenhan999
Copy link

Hi 请教一下 集成spring cloud gateway之后,流控规则是如何持久化呢?

@li7hai26
Copy link
Contributor

li7hai26 commented Mar 5, 2020

流控规则持久化,我看了下,应该是和之前一样的,继续加DynamicRuleProvider DynamicRulePublisher,改GatewayApiController,GatewayFlowRuleController

@chenhan999
Copy link

流控规则持久化,我看了下,应该是和之前一样的,继续加DynamicRuleProvider DynamicRulePublisher,改GatewayApiController,GatewayFlowRuleController

在2个controller中都没有发现DynamicRuleProvider 、DynamicRulePublisher 相关的引用呢

@chenhan999
Copy link

流控规则持久化,我看了下,应该是和之前一样的,继续加DynamicRuleProvider DynamicRulePublisher,改GatewayApiController,GatewayFlowRuleController

浏览了一下,是需要自己改造一个类似FlowControllerV2 的GatewayFlowRuleControllerV2类是吧?请问下,您那边之前有改造过吗,方便提供一份吗?

@sczyh30 sczyh30 changed the title spring cloud gateway(2.2.0) 使用 sentinel(1.7.1),普通限流无效果 spring cloud gateway(2.2.0) + spring-cloud-alibaba-sentinel-gateway,网关限流规则不生效 Mar 13, 2020
@tanaduus
Copy link

我在自己的项目META-INF/services里面加了一个自己的SlotChainBuilder(复制于GatewaySlotChainBuilder),期待ServiceLoader的迭代顺序能早于HotParamSlotChainBuilder,结果果然成功了,网关流控也生效了。不过我的办法还是很怪异,希望有最新的版本修正这个问题。

@sczyh30 sczyh30 changed the title spring cloud gateway(2.2.0) + spring-cloud-alibaba-sentinel-gateway,网关限流规则不生效 Slot Chain 加载顺序问题导致网关限流规则不生效 Apr 3, 2020
@sczyh30
Copy link
Member

sczyh30 commented Apr 3, 2020

Refer #411 and #1308. Closing this issue as it will be improved in 1.7.2.

@sczyh30 sczyh30 closed this as completed Apr 3, 2020
@sczyh30 sczyh30 changed the title Slot Chain 加载顺序问题导致网关限流规则不生效 Slot Chain 加载顺序问题导致网关限流规则不生效 order of the slot chain builder confusing May 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/gateway-flow-control Issues or PRs related to API gateway flow control
Projects
None yet
Development

No branches or pull requests

6 participants