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

Realize the meituan Oceanus design inside #2

Open
Maybrittnelson opened this issue Feb 28, 2019 · 4 comments
Open

Realize the meituan Oceanus design inside #2

Maybrittnelson opened this issue Feb 28, 2019 · 4 comments

Comments

@Maybrittnelson
Copy link
Owner

Oceanus策略结构定义

name:策略名,没有实际意义,可以根据业务场景进行定义。
key:分流时依赖的关键字,比如要根据城市地域进行分发路由时,key就是regionid。
passway:关键字在HTTP协议中的传输方式,可以是Parameter、Cookie、header、body中的一种。
condition:表达式模板,支持四则运算/取模、关系运算符、逻辑运算符等。
group:后端服务集群,即匹配策略后,转发请求的目标节点,一般是策略所属应用集群中的部分节点。
category:策略类型,如果为1,表示某个服务的私有策略;如果为2,表示公共策略,主要用于策略数据管理。
switch:策略开关,用于控制当前策略是在线还是离线。
graylist:灰度列表,用于策略变更的线上灰度校验。

对比

✅name(对应route的id)
❌key(regionid城市分组,分流依赖)
✅passway(对应route的perdicate。cookie,header,query,没有body)
❌condition(表达式模版,支持四则运算/取摸,关系运算符,逻辑运算符等。perdicate只有取摸运算)
✅group(对应可以1. uri固定地址,2. ribbon负载)
❌category(私有策略,公共策略。一个route就相当于一个私有策略,无法公共)
✅switch(修改某个route中的perdicate、filter、uri)
❌graylist()

@Maybrittnelson
Copy link
Owner Author

Maybrittnelson commented Mar 6, 2019

@Maybrittnelson
Copy link
Owner Author

Maybrittnelson commented Mar 6, 2019

✅灰度发布

use WeightRoutePredicateFactory, and fix fisrt request 404

org.springframework.cloud.gateway.filter.WeightCalculatorWebFilter#onApplicationEvent
use PredicateArgsEvent

如何获取

@Maybrittnelson
Copy link
Owner Author

Maybrittnelson commented Mar 7, 2019

✅限流

use RequestRateLimiterGatewayFIlterFactory

org.springframework.cloud.gateway.filter.ratelimit.AbstractRateLimiter#onApplicationEvent
use FilterArgsEvent put Config to RedisRateLimiter

代办原理

org.springframework.cloud.gateway.filter.factory.HystrixGatewayFilterFactory#apply(org.springframework.cloud.gateway.filter.factory.HystrixGatewayFilterFactory.Config)

令牌桶算法

redis-rate-limiter.replenishRate: 1 每秒填充速率,redis-rate-limiter.burstCapacity: 2 总容量,
我发起3个请求,每秒两个(ab -c 2 -n 3 http://localhost:9091/user/find/all ),会成功2个失败1个,原因是第2秒才开始填充1个,我在第2秒再发起剩余的1个请求(如果先填充后请求就成功。如果先请求后填充就失败)。

@Maybrittnelson
Copy link
Owner Author

✅熔断

use HystrixGatewayFilterFactory

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

1 participant