I have set up a test gateway, where I have 3 consumers, A, B, C and a service X. I want to set up a rate limiting policy so service X has 10 request per minute limit, A is only allowed 5 requests per minute, B and C have no specific limits but are bound by the general limit of X.
I tried to achieve this by creating 2 instances of the rate limiting plugin, I configured the general limit by:
curl --location 'http://localhost:8001/services/X/plugins' \ --form 'name="rate-limiting"' \ --form 'instance_name="general_limit"' \ --form 'config.minute="10"' \ --form 'config.policy="local"'
And consumer A’s limit by:
curl --location 'http://localhost:8001/consumers/<Consumer-A-ID>/plugins' \ --form 'name="rate-limiting"' \ --form 'instance_name="A_limit"' \ --form 'config.minute="5"' \ --form 'service.id="<Service-X-ID>"' \ --form 'config.policy="local"'``` I also tried adding the second plugin on the service endpoint with the added --form 'consumer.id="<Consumer-A-ID>"' \ However in both methods, the behavior is not as desired. I am expecting if B and C combined send more than 10 requests, the rest of the requests are blocked until the limit refreshes, this holds true for B and C, however after sending the 10 requests, consumer A is still able to send 5 more and then he gets blocked by the second plugin instance. I figured this was expected because only one instance of the same plugin runs per request. However I still need to achieve this behavior and I am not sure how to do it. Is creating a custom plugin that gets applied on a service level and is configured to handle different limits for different consumers a viable method?