Throttling pattern

A typical cloud application can have a variable load over time based on different situations such as a number of concurrent requests, a number of active users over time, types of actions that the application must perform and so on. In each of these situations, resources could become insufficient and the application could have poor performances or it could have a failure.

One common way to handle these situations is to scale the application accordingly by adding more instances, but as you can imagine this approach has two main side-effects—costs and time to scale up a new instance.

The Throttling pattern is an approach that permits a cloud application to use resources up to a defined limit. When the limit is exceeded, the client is throttled for a certain period of time and during this time, the cloud application blocks all requests from that client. The cloud application should return an exception to the client indicating the throttling reason.

A standard schema for the Throttling pattern is described in the following diagram:

Azure Resource Manager (ARM) limits read requests to 15,000 per hour and write requests to 1,200 per hour for a single ARM instance, for each subscription and tenant. If the request limit is reached, your application receives an HTTP status code 429 too many requests and a Retry-After value in the header. The Retry-After value specifies the number of seconds that your application should wait before sending a new request. If the application sends a request before the Retry-After value has elapsed, the request is not processed and ARM returns a new Retry-After value.

If in your business scenario, you have multiple concurrent applications that make requests on the same subscription, all the requests are added together to determine the number of remaining requests. Each response header of every request includes values for the number of remaining read and write requests.

For example, in C#, you can retrieve the remaining number of the subscription scoped reads  by checking the header value from an HttpWebResponse object (here called response) with the following line of code:

response.Headers.GetValues("x-ms-ratelimit-remaining-subscription-reads").GetValue(0)

These response headers values are listed in the following link: https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-manager-request-limits.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.191.233.205