In this video , We will see how to throttle the number of concurrent connections to your API target server using ConcurrentRateLimitPolicy.
Consider a scenario where your backend server supports only X number of concurrent API calls. What if, there are more concurrent connections, say X + Y ? Most probably, Latencies will increase or server will die.
Let's say you would like to gracefully decline requests & send back 503 error response to the client. It's very simple to implement same in Apigee Edge by creating a proxy & using ConcurrentRateLimitPolicy. Apigee Intelligent API Platform also allows dynamic inbound connections throttling based on API flow variables to the target endpoint using the same policy.
Above proxy demonstrates how to restrict 2 concurrent connections to the target endpoint. To demonstrate same, We are using Node.JS target server with a delay of 20 seconds.
For example,
API Request 1 - Time 0th second - Allowed - Waiting for response
API Request 2 - Time 1st second - Allowed - Waiting for response
Any further requests till request 1 or 2 is completely processed will be restricted and given 503 response back the client.
You can find the proxy code here in github.
nice video - a really easy to understand demo! 🙂
Thank you @Sean Davis ..
Hi @Anil Sagar
Is the Concurrent Rate Limit Policy applied only at API Proxy level or also at API Product level like we have Quota Policy ?
Also suppose I have three API Proxies AP1, AP2, AP3 pointing to same backend having concurrent rate limit as 2,3,4 respectively then how it will behave ?
Does the total of 9 (2+3+4) concurrent hits are allowed for this backend coming from any of the AP1,AP2,AP3 ?
So will it start throwing error after 2nd concurrent hit to AP1 or after 10th concurrent hit to AP1 ?
Great Questions @GAURAV , Can you please post same as a new Question for better tracking ?