【soul】网关之【ratelimiter】插件之初体验

ratelimiter是一款限流插件,限流的级别可以精确到接口级,参数级。

使用Redis的令牌桶算法

1. 启动【soul-admin】和【soul-bootstrap】

2.登录管理界面,开启rate-limiter插件

3. 配置用户测试的选择器【ratelimiter-test】 

4. 配置规则【ratelimiter-test-rule】

 5. 启动【soul-examples-http】

6. 访问 /http/order/findById

curl http://localhost:9195/http/order/findById\?id\=1
{"id":"1","name":"hello world findById"}%

7. 使用压测工具进行熔断, 存在错误

wrk -t10 -c100 -d9s  http://localhost:9195/http/order/findById\?id\=1
Running 9s test @ http://localhost:9195/http/order/findById?id=1
  10 threads and 100 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency    35.29ms   45.26ms 260.33ms   84.69%
    Req/Sec   553.21    175.91     1.38k    69.67%
  49611 requests in 9.01s, 8.10MB read
  Non-2xx or 3xx responses: 48928
Requests/sec:   5503.50
Transfer/sec:      0.90MB

8. 再次访问 /http/order/findById,发生了熔断

curl http://localhost:9195/http/order/findById\?id\=1
{"code":429,"message":"You have been restricted, please try again later!","data":null}%

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值