shenyu icon indicating copy to clipboard operation
shenyu copied to clipboard

RedisRateLimiter#isAllowed “doFinally” execution sequence problem

Open WYUSIG opened this issue 5 years ago • 0 comments

After my test, I found that,RedisRateLimiter#isAllowed “doFinally” execution sequence is :

1.WebClientPlugin#execute send request

2.doFinally execution RateLimiterAlgorithm#callback

3.WebClientResponsePlugin#execute write response

I think a request needs to write response ,then execution RateLimiterAlgorithm#callback, because

Concurrent requests limiter:

“Because Redis is so fast, doing the naive thing works. Just add a random token to a set at the start of a request and remove it from the set when you're done. If the set is too large, reject the request.”

from https://gist.github.com/ptarjan/e38f45f2dfe601419ca3af937fff574d#file-1-check_request_rate_limiter-rb-L11-L34


so the doFinally It should be written in RateLimiterPlugin#doExecute,If so, then execution sequence is :

1.WebClientPlugin#execute send request

2.WebClientResponsePlugin#execute write response

3.doFinally execution RateLimiterAlgorithm#callback

WYUSIG avatar May 02 '21 04:05 WYUSIG