API calls: Difference between revisions
No edit summary |
|||
| Line 61: | Line 61: | ||
== Estimating API calls == | == Estimating API calls == | ||
The following formulas can give you an estimate of API calls made during the synchronization and online mode. Only the communication with | The following formulas can give you an estimate of API calls made during the synchronization and online mode. Only the communication with CRM server is counted. Calls to SharePoint/Exchange, etc., are not subject of any limit. | ||
=== Full synchronization === | === Full synchronization === | ||
Revision as of 09:40, 30 October 2019
An application programming interface (API) is a communication protocol or interface between client and server computers. When a client device requests data from the server, this is called an API call.
In our environment, Resco uses API calls to request data from the CRM server. Growing number of CRM server providers restrict the number of API calls per time period, or have pricing related to this number. Therefore, it becomes increasingly important to understand how and when Resco Mobile CRM talks to the CRM server. Fortunately, careful setup of your app project can help you optimize the number of API calls.
Dynamics 365 (March 2019)
Microsoft requirements:
- Max 4000 requests per sliding 300 seconds window.
- Combined execution time of incoming requests cannot exceed 1200 seconds over a time window of 300 seconds.
If the limit is exceeded, server returns HTTP error 429 (Too Many Requests), and the internal SOAP fault reports one of the following error:
- 2147015902 Number of requests exceeded the limit of 4000, measured over time window of 300 seconds.
- 2147015903 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.
- 2147015898 Number of concurrent requests exceeded the limit of X
Note: Existing MCRM version will display this error text to the user.
Dynamics limits (as of October 2019)
| User license | # API requests / 24 hr |
|---|---|
| D365 Enterprise apps | 20,000 |
| D365 Professional | 10,000 |
| D365 Team Member | 5,000 |
| etc. (more plans exist) |
From the perspective of Resco Mobile CRM app, practically all server calls count:
- All CRUD operations, share, assign.
- From any client/app, using SOAP/REST endpoints.
Important: Implied API calls issued by server plugins, (async) workflows etc. are counted, too.
Only a handful calls are ignored (do not count for the limit)
- login/logout
- getClientMetadata
Exceeding request capacity
What happens if any user exceeds the licensed request capacity? The current policy is that end users are not be blocked from using the app for occasional and reasonable over-consumption at this point of time. Dynamics admins are notified and they can assign PowerApps and Microsoft Flow request capacity to that user.
All existing customers have a transition period until October 1, 2020 or the expiration of their current subscription term, whichever is longer. During this period, customers gain access to Reporting (part of Power Platform Admin Center) that shows the API consumption.
Azure throttling
Azure is throttling Resource Manager requests. These limits are usually less important. They apply to Dynamics hosted on Azure, but also to RescoXRM hosted on Azure.
For each Azure tenant, Azure Resource Manager allows up to 12,000 read requests/hour and 1,200 write requests/hour. These limits are scoped to the security principal (user or app) making the requests and the subscription ID or tenant ID. If your requests come from more than one security principal, your limits increase.
Real limits are usually much higher, also because they apply to one ARM instance, while there are usually multiple ARM instances in your region.
If the limit is exceeded, server returns HTTP error 429 (Too Many Requests).
Estimating API calls
The following formulas can give you an estimate of API calls made during the synchronization and online mode. Only the communication with CRM server is counted. Calls to SharePoint/Exchange, etc., are not subject of any limit.
Full synchronization
Add the following numbers together to receive a rough estimate of API calls needed to perform a full synchronization in your project. Round up.
- ~15 for preparation phase (without new customization)
- number of entities / 2
- number of records / fetch_page_size
- number of NN records / 2000
- number of ActivityParty records / 2000
- number of attachments
- number of images
- 1 (if audit is used)
Incremental synchronization
Add the following numbers together to receive a rough estimate of API calls needed to perform an incremental synchronization in your project. Round up.
- ~11 for preparation phase (Same as for FullSync except permissions are loaded only at 1st sync after AppStart)
- +1 (DeletePlugin)
- number of changed entities (for uploader; see also comment below)
- number of entities * 1.2 (SyncAnalyzer + downloader)
- number of NN entities
Note for uploader: This maybe sound like a low number, but it is usually correct. However, there are some cases when uploader is quite costly:
- If you have many local changes (default batchsize=100) - this is typically the case for Inspections
- Every upload problem costs extra API calls (upload retries, conflict resolution...)
- Status changes cost extra calls
Online mode
All API calls go through online request queue. (They are serialized!)
Any serious work in online mode will sooner or later consume more API calls than sync. This is valid even for full synchronization of huge app projects. Why? Lot of actions generate several API calls. Extreme example: opening of a single complex form with several related / unrelated lists in online mode can take more than 40 API calls.
Views
- Open: 2 calls
- Browse: 2 calls / page (~50 items)
Forms
- Load: 2-50+ calls/form
- Save: 1 or more calls
Recommendations
Install newest release of Resco Mobile CRM app. Its sync log contains API call statistics in the following format:
<ApiCalls Prepare='...' Uploader='...' SyncAnalyzer='...' Downloader='...' Images='...' Total='1234' />
The value listed in Total attribute represents the total number of API calls made during the synchronization.
Notes:
- Salesforce/RescoXRM numbers are not reliable at this point. We are planning to correct this in v12.3 release.
- API calls issued by MCRM may induce additional API calls made by Server plugins. (This mainly concerns sync Uploader or Save operation in Online mode.)
- MCRM has no chance to know about these extra calls, but you should take them into consideration when making API calls estimates.
Below are some maxims how to minimize API calls number.
- Online mode
- Do not use New UI (Then the tabs are loaded on demand.)
- Synchronization
- Use large fetch page size (Advanced sync setup):
- By default 500 records = 1 API call.
- Using page size 5000 (maximum) decreases the number of API calls to one tenth. However, larger page size may result in lower app responsiveness and requires more memory.
- Decrease number of downloaded attachments (1 attachment = 1 API call)
- Minimize data downloaded by the client
- Avoid useless downloads:
- All records that are deleted in the FullSync cleanup need not be downloaded at all.
- SyncAnalyzer:
- Dynamics/RescoXRM: If you are sure you don't need this module, switch it off. You might save ~O(numEntities/10) API calls during IncSync.
- Salesforce: SyncAnalyzer saves a lot of API calls during IncSync. (Due to batching several requests into one API call.)
- Automatic synchronization
- Do not overuse. Normal IncSync takes ~50-100 API calls.