Baoyuantop commented on issue #12946:
URL: https://github.com/apache/apisix/issues/12946#issuecomment-3815756300

   Hi @falvaradorodriguez, I have confirmed that this is expected behavior, not 
a bug.
   
   By default, each route in APISIX has its own separate rate-limiting counter. 
We later introduced the `group` configuration option in the `limit-count` 
plugin to achieve the scenario you described. However, this configuration 
option has not yet been added to other rate-limiting plugins.
   
   The following test cases have been verified to pass.
   ```
   === TEST 1: setup consumer with group and routes
   --- config
       location /t {
           content_by_lua_block {
               local t = require("lib.test_admin").test
               -- consumer with limit-count: count=1, time_window=60, 
group="jack-limit"
               t('/apisix/admin/consumers', ngx.HTTP_PUT, [[{
                   "username": "jack",
                   "plugins": {
                       "key-auth": { "key": "auth-key" },
                       "limit-count": {
                           "count": 1,
                           "time_window": 60,
                           "rejected_code": 429,
                           "key": "consumer_name",
                           "group": "jack-limit"
                       }
                   }
               }]])
               -- route A
               t('/apisix/admin/routes/1', ngx.HTTP_PUT, [[{
                   "uri": "/hello", "plugins": { "key-auth": {} },
                   "upstream": { "nodes": { "127.0.0.1:1980": 1 }, "type": 
"roundrobin" }
               }]])
               -- route B
               t('/apisix/admin/routes/2', ngx.HTTP_PUT, [[{
                   "uri": "/hello1", "plugins": { "key-auth": {} },
                   "upstream": { "nodes": { "127.0.0.1:1980": 1 }, "type": 
"roundrobin" }
               }]])
               ngx.say("done")
           }
       }
   --- request
   GET /t
   --- response_body
   done
   
   
   
   === TEST 2: cross-route requests - with group, counter is shared globally
   Consumer has count=1 with group="jack-limit", requests across routes share 
the same counter.
   EXPECTED: [200, 429]
   --- pipelined_requests eval
   ["GET /hello", "GET /hello1"]
   --- more_headers
   apikey: auth-key
   --- error_code eval
   [200, 429]
   
   ```


-- 
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]

Reply via email to