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

限流算法与实现 #1

Open
TFdream opened this issue Mar 16, 2021 · 0 comments
Open

限流算法与实现 #1

TFdream opened this issue Mar 16, 2021 · 0 comments

Comments

@TFdream
Copy link
Owner

TFdream commented Mar 16, 2021

漏桶算法

想象有一个水桶,水桶以一定的速度出水(以一定速率消费请求),当水流速度过大水会溢出(访问速率超过响应速率,就直接拒绝)。

漏桶算法的两个变量:

  • 水桶漏洞的大小:rate
  • 最多可以存多少的水:burst

令牌桶算法

系统按照恒定间隔向水桶里加入令牌(Token),如果桶满了的话,就不加了。每个请求来的时候,会拿走1个令牌,如果没有令牌可拿,那么就拒绝服务。

参考资料

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