Hello everyone!
Welcome to Kaizen! This week, we will discuss credit calculation and concurrency in Zoho CRM APIs.
Credit calculation
API rate limiting is crucial to ensure fair resource distribution, maintain optimal service quality for all users, and safeguard our system from potential security threats. It helps us provide a consistent, reliable, and secure service to every user, while encouraging efficient and thoughtful API usage. API Usage in a CRM organization is calculated based on credits. When you make an API call, a specific number of credits are deducted from the total number of credits available to you. The number of credits available to you differs depending on the edition and user licence purchased. Below table shows the same.
Edition | Allowed Credits | Maximum Credits |
Free Edition
| 5000 credits | 5000 credits
|
Standard/Starter Edition
| 50,000 credits + (Number of User licenses x 250) + Add-on credits | 100,000 credits
|
Professional
| 50,000 credits + (Number of User licenses x 500) + Add-on credits | 1,000,000 credits
|
Enterprise/Zoho One | 50,000 credits + (Number of User licenses x 1000) + Add-on credits | 2,000,000 credits
|
Ultimate/CRM Plus
| 50,000 credits + (Number of User licenses x 2000) + Add-on credits | Unlimited
|
The API Rate Limit is for a rolling window of 24 hours i.e., for every API call, we will check the API credits consumed in the last 24 hours to see whether the current API call can be allowed or not. When you make the very first API call , a 24 hour window begins. The API credits you used at each time interval will be freed up after 24 hours corresponding to each time interval.
Consider the above example where we assume that you are making API calls starting from 9 AM. The total available credits are 5000. For simplicity, let us consider that there are no API calls made on the previous day and no additional credits were purchased.
Between 9:00 AM and 9:05 AM on day 1, you use up 100 credits and you are left with 4900 credits . Since no API calls were made the previous day, you have no API credits getting freed up at that time. Between 9:05 AM and 9:10 AM, you use up 150 credits, leaving you with 4750 credits. Let us assume that you exhausted your available limit by 8.45 AM the next day.
At 9 AM on day 2, 100 API credits used on the previous day (day 1) will be freed up. Similarly, at 9:05 AM on day 2 , 150 credits will be freed. In this case API calls between 8:45 AM and 9 AM will result in system errors.
Let us consider the same scenario if you had purchased add-on credits. After you exhaust your available limit by 8:45 AM on day 2, the credits for further API calls will be considered from the purchased add-on credits. At 9 AM, when the 100 API credits used on the previous day are freed up they are available for your use instead of add-on credits.
Concurrency
In addition to 24 hour rolling window throttler, Zoho CRM has concurrency limit being applied for APIs. It will limit the no of parallel API calls being active at one time instance. Concurrency limit is checked per org per OAuth app. Concurrency limit differs based on your Zoho CRM edition.
Edition | Concurrency limit for an Org/App |
Free | 5 |
Standard/Starter | 10 |
Professional | 15 |
Enterprise/Zoho One | 20 |
Ultimate/CRM Plus | 25 |
Let's assume your organization has a concurrency limit set at 10. A sequence of API calls are made one after another. When all these API calls are still in process with each API call you make, the number of concurrent API calls increases incrementally. Initially, when you make the first API call, concurrency is 1. For the second API call made before the end of the first API call, concurrency becomes 2, and so on. This scenario is shown in the picture above. Once you reach the 10th API call, concurrency reaches its maximum limit of 10. As a result, the 11th API call fails.
However, let's assume that the 5th API call completes its process, thereby reducing the concurrency level to 9. In this state, the 12th API call can be made successfully without encountering any errors.
Sub-concurrency
Some APIs will take much more computing resources than other APIs. For example, an Insert Records API call for a 1000 records will take much more resources than a Get Leads API call for a particular lead id.
For such APIs, we'll apply a separate concurrency limit namely sub-concurrency limit to ensure that the APIs are being used responsibly. The APIs that will falls under the sub-concurrency limit are
- Get Records with cvid or sort_by parameters
- Convert Lead
- Insert, Update, or Upsert records (when the record count is greater than 10)
- Send Mail
- Search records API invoked from function
- Query API
- Composite API
Across all editions of Zoho CRM, the sub-concurrency limit is set as 10. You can make 10 concurrent requests for a combination of the above listed APIs or 10 concurrent requests of one of the APIs. However, if the total number of sub-concurrent requests exceeds 10, the system will generate a "TOO_MANY_REQUESTS" error.
Let's understand how concurrency and sub-concurrency apply together to your API calls. Assume that in your organization, the concurrency limit is set at 12 and sub-concurrency limit is set at 10.
We'll consider a case where send mail API call has been fired in parallel 11 times, for which the sub-concurrency is applicable. For the first 10 send mail API calls, there won't be any error and sub-concurrency limit will reach it's maximum allowed limit of 10. When the 11th API call is made, the error "TOO_MANY_REQUESTS" will be thrown even though the concurrency limit of 12 has not reached .
Now, let's consider the 12th API call, doesn't fall under the category of API calls subject to the sub-concurrency limit, say it is a normal GET records call with just fields & ids parameter. This call goes through successfully without encountering any errors. Similarly, the 13th API call, a GET user API call, also goes through. At this point, the concurrency is 12, and the concurrency limit is set at 12 as well. The 14th API call will result in an error because the concurrency limit exceeded. In short, the number of API calls allowed at a time depends on the concurrency limit and sub-concurrency limit.
We hope you found this post useful and it increased your understanding. Stay tuned for more.
Cheers!
Mable