Search code examples
c#dynamics-crmmicrosoft-dynamicsdynamics-365dynamics-crm-webapi

Is there a way to bypass the updated Dynamics 365 web API limits on concurrent queries


The Dynamics 365 Web API throws the following error when I am trying to migrate multiple batches of records to the CRM:

Combined execution time of incoming requests exceeded limit of 1,200,000 milliseconds over time window of 300 seconds. Decrease number of concurrent requests or reduce the duration of requests and try again later.

I am using parallel for loop to migrate multiple batches of data to the CRM using the Web API. I need to have a high throughput as I need to migrate millions of records in a limited amount of time.

Is there a way to bypass this problem? Limiting the number of threads leads to the throughput taking a major hit. I need a solution so that I can migrate hundreds of batches at the same time (concurrently).

I am using Web API v9.1 of dynamics 365. I am using the parallel for loop and in each iteration, a chunk of data is picked up (let's say a batch size of 500) and that thread migrates those 500 records to the CRM. I want multiple threads of 500 records each to be migrated to the CRM.

I tried solving this by using multiple users (as the limit is only per user) but that solution was not accepted by the client.

Another solution was to reduce the number of concurrent threads. This led to reduced throughput.

I don't want to limit the number of threads. Is there a work-around for this problem?


Solution

  • The API Limits are documented features.

    The limit will help provide a level of protection from random and unexpected surges in request volumes that threaten the availability and performance characteristics of the Dynamics 365 platform.

    There isnt really a way to switch them off. You could try raising a support ticket with Microsoft to see if they will, but it seems like they exist to protect the platform for all users (not just your customer) so don't hold your breath.

    The documentation itself has an answer though it probably isnt the one you want.

    If you get these responses, your application should stop sending API requests until the volume of requests is below the limit.

    A couple of things you could look into:

    1. Multiple users; your customer said no, but you didnt say why. If it was a concern over licence costs you could create multiple non-interactive user accounts.

    Since the administrative user does not have access to customer data and any of the customer engagement functionalities, it does not require a Dynamics 365 for Customer Engagement apps (online) license (after setup).

    1. Use ExecuteMultiple to improve performance for bulk data load.

    You can use the ExecuteMultipleRequest message to support higher throughput bulk message passing scenarios in Dynamics 365 for Customer Engagement , particularly in the case of Dynamics 365 for Customer Engagement apps where Internet latency can be the largest limiting factor.

    There are you some limitations to this approach.

    • No recursion is allowed.
    • Maximum batch size is 1000 by default.
    • There is a limit of 2 concurrent ExecuteMultipleRequest executions per organization.

    Somewhat aside, from experience Dynamics data migrations can take a long time to complete and often the best solution to this problem is patience.


    Edit: Quite a lot has changed since I wrote this way back in...April(!)

    If you on the Power Platform (e.g. CRM/CE/Dynamics Online) using the Common Data Service; head over to Common Data Service API limits overview to see how the new limits work. Furthermore the concurrent limit on ExecuteMultiple has been removed (and replaced with the API limits above).