I am using wso2-am 2.0.0 to achieve rate limiting for APIs. I have published an API with one user and it is then subscribed by another user. While subscribing, I am selecting a subscription tier of 20 requests per minute for that API. Also, the Application used to subscribe to the API, has a limit of 50 requests per minute. Now, when I am testing the API, only Application level rate limiting is happening after around 50 requests. The API level limit is not applied. Ideally the user should not be able to access the API after 20 requests. I am using windows machine to setup the wso2 server and Apache JMeter to send requests to the server. What am I missing here? Need some help...
1 Answers
0
votes
Here is a 4MB/s policy.
@Plan:name('carbon.super_app_BandwidthPolicy')
@Plan:description('ExecutionPlan for app_BandwidthPolicy')
@Import('org.wso2.throttle.processed.request.stream:1.0.0')
define stream RequestStream (messageID string, appKey string, appTier string, subscriptionKey string, apiKey string, apiTier string, subscriptionTier string, resourceKey string, resourceTier string, userId string, apiContext string, apiVersion string, appTenant string, apiTenant string, appId string, apiName string, propertiesMap string);
@Export('org.wso2.throttle.globalThrottle.stream:1.0.0')
define stream GlobalThrottleStream (throttleKey string, isThrottled bool, expiryTimeStamp long);
FROM RequestStream
SELECT messageID, (appTenant == 'carbon.super' and appTier == 'BandwidthPolicy') AS isEligible, appKey AS throttleKey, propertiesMap
INSERT INTO EligibilityStream;
FROM EligibilityStream[isEligible==true]#throttler:timeBatch(1 min, 0)
select throttleKey, (sum(cast(map:get(propertiesMap,'messageSize'),'long')) >= 4194304) as isThrottled, expiryTimeStamp group by throttleKey
INSERT ALL EVENTS into ResultStream;
from ResultStream#throttler:emitOnStateChange(throttleKey, isThrottled)
select *
insert into GlobalThrottleStream;
wso2am-2.0.0/repository/deployment/server/executionplans? - Bee