Sentinel 针对IP限流
Sentinel
alibaba/Sentinel: Sentinel 是阿里巴巴开源的一款面向分布式服务架构的流量控制、熔断降级组件,提供实时监控、限流、降级和系统保护功能,适用于微服务治理场景。
项目地址:https://gitcode.com/gh_mirrors/sentine/Sentinel
·
Sentinel 可以简单实现针对IP的限流,通过改造限流策略的针对来源选项
1.首先我们要自定义来源解析RequestOriginParser
@Configuration
public class SentinelConfig {
@Bean
public RequestOriginParser requestOriginParser() {
return (request -> {
String remoteAddr = IpUtils.getRemoteAddr(request);
return remoteAddr;
});
}
}
2.接下来我们设置来源 ,填入限制的ip,如:(这边一般通过如nacos全局去配置)

3.测试结果,Sentinel只针对来源IP限流
alibaba/Sentinel: Sentinel 是阿里巴巴开源的一款面向分布式服务架构的流量控制、熔断降级组件,提供实时监控、限流、降级和系统保护功能,适用于微服务治理场景。
最近提交(Master分支:2 个月前 )
a08dc695
* Fix the bugs mentioned in issue #3562 and #3563.
Fix the issue in the spring-webmvc-v6x-adapter where, after configuring http-method-specify:true, the prefixes for different request methods were not concatenated.
Fix incorrect time unit in the tooltip when adding a new circuit breaker rule with statistical window duration.
* Fix the bugs mentioned in issue #3562 and #3563.
Fix the issue in the spring-webmvc-v6x-adapter where, after configuring http-method-specify:true, the prefixes for different request methods were not concatenated.
Fix incorrect time unit in the tooltip when adding a new circuit breaker rule with statistical window duration.
* Fixed the issue where the original test class was affected by the concatenation of resource names after adding the logic for the HTTP prefix concatenation.
* remove mseHttpMethodSpecify field and update the unit test as suggested.
* retrigger CI 17 天前
e60f0d0e
* Simple rules should have higher priority than regular expression rules
* Add optional switch to skip regex matching when simple rules already match, default: false, keeps backward compatibility.
* fix RuleManagerTest unit test failure 17 天前
新一代开源开发者平台 GitCode,通过集成代码托管服务、代码仓库以及可信赖的开源组件库,让开发者可以在云端进行代码托管和开发。旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。
更多推荐


所有评论(0)