PL 400 : implement API limit retry policies (Use platform APIs)

API limits act as guardian to control random and unpredictable surges in API request volume. A large number of requests create availability problems and reduce performance, in other words, API limits ensure the health and accessibility of the API. With HTTP API requests, this error usually appears as a response with a 429 status code. It also sends additional information to indicate the time required to wait until another request is attempted. This header is usually called "Retry-After".


Dataverse API limits help ensure service level, availability, and quality. Dataverse API limits are part of the Power Platform request limit and allocation. There are two categories of limits that apply for Dataverse.

  • Entitlement limits
  • Service Protection limits
Entitlement limits:

Entitlement limits are associated with type of license assigned to each user. If user exceeds their requests, the administrator would be notified.

Service Protection limits:

To maintain the performance and availability, Microsoft applies some limits on Dataverse API usages. Such limitations only effect to large number of API requests to prevent to surge the unexpected and random requests. The limit also apply on concurrent connection per user account, the number of API request per connection, and the amount of execution time. When one of these limits is exceeded an exception will be thrown by the platform.

Service protection limits apply to all external web service requests.

Microsoft always recommends to apply patterns to retry operations after a period of time when these exception are returned. These limits are designed to detect when client applications are making extraordinary demands on server resources.

The limit doesn't effect the normal users of interactive clients.

Plug-ins and custom workflow activities implement business logic triggered by incoming requests. Service security limits do not apply to plug-ins and custom workflow activities. Plug-ins and custom workflow activities are uploaded and run within an isolated sandbox service. Dataverse operations implemented on a sandbox service do not use a public API endpoint.

Retry Operation:

When a Service protection  API limit error occurs, it will provide a value indicating the length of time before any new requests from the user are processed.
  • When a 429 error is returned from the Web API, the response will include a Retry-After with number of seconds.
  • With OrganizationService, a TimeSpan value is returned in the OrganizationServiceFault.ErrorDetails collection with the key Retry-After.
In an interactive application re-try, the developer should display a message that the server is busy while the user retry the request made by the user and try again in a non-interactive application re-try, leaving the client application to simply wait before the period elapses. Must practice is sending request again.

The service protection API limits are evaluated per user.

Service protection API limits are enforced based on three facets:
  • The number of requests sent by a user.
  • The combined execution time required to process requests sent by a user.
  • The number of concurrent requests sent by a user.


The availability of servers depends on multiple factors, but each web server of environment will enforce these limits independently. As known, most environment will have more than one web server. Trial environments are allocated only a single web server.

The Retry-After duration will depend on the nature of the operations that have been sent in the preceding 5 minute period.

Conclusion:

The API limit does not impose any restrictions in use, obviously, it helps to increase performance and availability for all. Sometimes, developers write code without reading the documentation or unintentionally misuse the resource consumption, such limit prevents such incidents. Microsoft provides unlimited resources for commercial use, but also implements mechanisms that help use the Dataverse API in customizable ways.

Comments

Popular posts from this blog

PCF vs. Web Resources: Choosing the Right Extensibility Tool for Dataverse

Is Debt Prosperity or Trap?

Exam PL-400: Microsoft Power Platform Developer