ynsdl commented on issue #7872:
URL: https://github.com/apache/apisix/issues/7872#issuecomment-1239316413
@kingluo I tried serverless but I think it not working correctly.
when I make yyy limit 100, xxx also affect from this limit. I assume that
xxx should affect own limit. yyy limit shouldnt affect xxx limit
`"functions" : ["local lr = require(\"apisix.plugins.limit-req\"); local
limits = {xxx=1, yyy=100}; return function(conf, ctx) if
ctx.var.http_x_yunus_api_key and limits[ctx.var.http_x_yunus_api_key] then
local rate = limits[ctx.var.http_x_yunus_api_key]; return lr.access({rate =
rate, burst = rate, rejected_code = 503, key_type = \"var\", key =
\"http_x_yunus_api_key\"}, ctx); end; end"]`
xxx limit is 1 but there is no failed transaction.
```
siege -t4s -c15 --content-type "application/json" -H 'X-yunus-api-key: xxx'
'https://example.com'
Lifting the server siege...
Transactions: 97 hits
Availability: 100.00 %
Elapsed time: 2.69 secs
Data transferred: 0.02 MB
Response time: 0.28 secs
Transaction rate: 36.06 trans/sec
Throughput: 0.01 MB/sec
Concurrency: 10.14
Successful transactions: 104
Failed transactions: 0
Longest transaction: 0.38
Shortest transaction: 0.23
```
yyy limit 100. it seems ok.
```
siege -t4s -c15 --content-type "application/json" -H 'X-yunus-api-key: yyy'
'https://example.com'
Lifting the server siege...
Transactions: 79 hits
Availability: 100.00 %
Elapsed time: 2.18 secs
Data transferred: 0.01 MB
Response time: 0.27 secs
Transaction rate: 36.24 trans/sec
Throughput: 0.01 MB/sec
Concurrency: 9.93
Successful transactions: 81
Failed transactions: 0
Longest transaction: 0.38
Shortest transaction: 0.24
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]