apply rate limiting policy
TRANSCRIPT
![Page 1: Apply Rate Limiting Policy](https://reader035.vdocument.in/reader035/viewer/2022062823/5871b4c51a28abda6a8b7697/html5/thumbnails/1.jpg)
APPLY RATE LIMITING POLICYWITH MULESOFT API GATEWAY
Vince Jason Soliza
![Page 2: Apply Rate Limiting Policy](https://reader035.vdocument.in/reader035/viewer/2022062823/5871b4c51a28abda6a8b7697/html5/thumbnails/2.jpg)
Pre-requisites
• API in Mulesoft API Gateway– e.g. http://www.slideshare.net/VinceSoliza/proxy-existing-soap-web-service
![Page 3: Apply Rate Limiting Policy](https://reader035.vdocument.in/reader035/viewer/2022062823/5871b4c51a28abda6a8b7697/html5/thumbnails/3.jpg)
Apply Policies in API ManagerThis presentation will show how to apply Rate Limiting Policy in API Gateway using Anypoint Platform for APIs
![Page 4: Apply Rate Limiting Policy](https://reader035.vdocument.in/reader035/viewer/2022062823/5871b4c51a28abda6a8b7697/html5/thumbnails/4.jpg)
Run in Anypoint Studio• Run the api application in anypoint studio
Note: Make sure the default api gateway port of 8081 is available.Skip this step if running with API Gateway Standalone outside Anypoint Studio or if deployed in Cloudhub.
![Page 5: Apply Rate Limiting Policy](https://reader035.vdocument.in/reader035/viewer/2022062823/5871b4c51a28abda6a8b7697/html5/thumbnails/5.jpg)
Apply Rate Limiting Policy• Login to anypoint platform and open the API Manager where we want to
apply the policy
• Click the Policies tab in the bottom part of the API Manager
![Page 6: Apply Rate Limiting Policy](https://reader035.vdocument.in/reader035/viewer/2022062823/5871b4c51a28abda6a8b7697/html5/thumbnails/6.jpg)
Apply Rate Limiting Policy• We can view the list of applied and currently available policies within the
API. Currently we have no applied policies.
• Look for the Rate Limiting policy then click Apply
![Page 7: Apply Rate Limiting Policy](https://reader035.vdocument.in/reader035/viewer/2022062823/5871b4c51a28abda6a8b7697/html5/thumbnails/7.jpg)
Apply Rate Limiting Policy• Set 10 Requests per second as our limit. Click Apply.
• Now we have successfully applied the Rate Limit policy
![Page 8: Apply Rate Limiting Policy](https://reader035.vdocument.in/reader035/viewer/2022062823/5871b4c51a28abda6a8b7697/html5/thumbnails/8.jpg)
Test Before Policy is Applied• Run the API using SOAPUI Load Test Runner with 20 requests per second
for 10 seconds.
• With a tps of 23.76 it accepts all the requests without a single exception.
![Page 9: Apply Rate Limiting Policy](https://reader035.vdocument.in/reader035/viewer/2022062823/5871b4c51a28abda6a8b7697/html5/thumbnails/9.jpg)
Test After Policy is Applied• Run the API using SOAPUI Load Test Runner with 20 requests per second
for 10 seconds.
• With a tps of 24.51 for 10 seconds there are 156 exceptions with error message: Tue Feb 23 12:53:37 PHT 2016:DEBUG:Receiving response: HTTP/1.1 429 Too Many Requests. This is because we set the rate limit policy to 10 requests per second only.It rejects the incoming request when the limit has been reached.
![Page 10: Apply Rate Limiting Policy](https://reader035.vdocument.in/reader035/viewer/2022062823/5871b4c51a28abda6a8b7697/html5/thumbnails/10.jpg)
Summary
• Rate limiting is used to control the rate of traffic sent or received by a network interface controller.
• A policy is a mechanism the gateway uses to enforce filters on traffic as it flows through the gateway. The Anypoint Platform for APIs comes with a number of pre-built policies including Rate Limiting, Throttling, OAuth 2, Basic HTTP Authentication, and XML and JSON threat protection.
https://docs.mulesoft.com/anypoint-platform-for-apis/api-gateway-101#what-is-a-policy
![Page 11: Apply Rate Limiting Policy](https://reader035.vdocument.in/reader035/viewer/2022062823/5871b4c51a28abda6a8b7697/html5/thumbnails/11.jpg)
QUESTIONS?Please leave a comment