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

[feature] basic cluster concurrent flow control #1687

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

yunfeiyanggzq
Copy link
Contributor

@yunfeiyanggzq yunfeiyanggzq commented Aug 21, 2020

Describe what this PR does / why we need it

这个pr是 #1631 (已合并)的延续,应该在其后合并
图片

本pr是 #1631 基础上完成的,已经实现了集群并发控制的基本功能,实现了控制并发数,应对客户端掉线、资源调用超时等情况,优先级请求block的阻塞策略请见下一个pr
四个commit分别完成以下功能:
完善client端,补充netty的encoder和decoder,完成DefaultTokenServerClient,注意释放token是异步通信,不管释放结果
完善server端,补充netty的processor、encoder、decoder,接入concurrentflowrulechecker,实现服务端流控规则管控
将集群并发控制接入sentinel core,将前两个pr的流控接入到flow slot。
完成demo

Does this pull request fix one issue?

Fixes #1697

Describe how you did it

Describe how to verify it

运行demo: https://github.com/yunfeiyanggzq/Sentinel/tree/pr2/sentinel-demo/sentinel-demo-cluster/sentinel-demo-cluster-concurrent ,分别运行server和client,可以体验分布式集群控制效果,可以通过print打印流控效果,也可以通过日志sentinel-server.log看流控记录,日志每秒打印并发控制信息并不是非常准确,但是能够大致反应流控情况。
nacos配置如下:

[
    {
      "clusterConfig":{
      "clientOfflineTime":3000,   // server端保存掉线client持有token的最长时间
      "fallbackToLocalWhenFail": true,
      "flowId":111,
      "resourceTimeout":2000,  // client端资源调用超过这个时间后执行resourceTimeoutStrategy策略
      "resourceTimeoutStrategy":1,// 0: 由server释放超时token,1:由client释放超时token
      "sampleCount":10,
      "strategy":0,
      "thresholdType":1,
      "windowIntervalMs":1000
       //此功能下个pr可用
    // "acquireRefuseStrategy":0, // 当优先级请求block执行的策略,0:忽略直接block,1:client再次请求,2:client多次请求直到成功,3.server阻塞队列等待获取,最大等待时间是maxQueueingTimeMs参数,队列最大大小为1000
    },
    "clusterMode":true,
    "controlBehavior":0,
    "count":100.0,
    "grade":0,
    "limitApp":"default",
    "maxQueueingTimeMs":500, // 在并发控制是服务端阻塞队列的最大等待时间。
    "resource":"cluster-resource",
    "strategy":0,
    "warmUpPeriodSec":10
   }
]

Special notes for reviews

本pr合并后我将完成集群并发控制的使用文档形成pr

@yunfeiyanggzq yunfeiyanggzq changed the title basic cluster flow control [feature] basic cluster concurrent flow control Aug 21, 2020
@yunfeiyanggzq yunfeiyanggzq force-pushed the pr2 branch 2 times, most recently from 8fe4fa6 to 690f140 Compare August 22, 2020 00:49
@sczyh30 sczyh30 added area/cluster-flow Issues or PRs related to cluster flow control size/XXL Indicate a PR that changes 1000+ lines. to-review To review labels Sep 1, 2020
Signed-off-by: yunfeiyanggzq <yunfeiyang@buaa.edu.cn>
Signed-off-by: yunfeiyanggzq <yunfeiyang@buaa.edu.cn>
…o sentinel core

Signed-off-by: yunfeiyanggzq <yunfeiyang@buaa.edu.cn>
Signed-off-by: yunfeiyanggzq <yunfeiyang@buaa.edu.cn>
@yunfeiyanggzq
Copy link
Contributor Author

yunfeiyanggzq commented Sep 16, 2020

@sczyh30 @cdfive @jasonjoo2010 please cc

@yunfeiyanggzq
Copy link
Contributor Author

@sczyh30 please cc if you have time !

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/cluster-flow Issues or PRs related to cluster flow control size/XXL Indicate a PR that changes 1000+ lines. to-review To review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[docs]ASoC2020结题总结(集群并发控制)
3 participants