The API throttling is a credit-based system with bursting capabilities and built-in protection against thread starvation issues. Below are the parameters that affect how the API throttling works:
Paramater | Default Value |
---|---|
Milliseconds it takes for a customer to earn 1 credit | 500ms |
Maximum number of credits that can be accumulated | 10000 |
Maximum number of threads that can be throttled at any given time | 4 |
First thing to keep in mind when learning about the Infusionsoft rate limiting system is that throttling happens only for the app, not for the API client. For example, if a customer purchases 3 add-ons, each of the add-ons must compete with the others for the API credits.
Every application starts with 0 credits. For every 500ms the application does not get any API traffic, one credit is rewarded. If nothing happens after about an hour, the application will reach its max number of allowed credits (max credits will always be 10,000).
Now, let's suppose the customer starts with a large sync of his database. In this example, we'll start with 10,000 records. The customer's API client will blow through the 10,000 accumulated credits as fast as it can until credits hit zero. Once it hits zero, the customer will have to wait for 500ms to earn one new credit. Each subsequent call will be blocked (on the Infusionsoft side) until 500ms has passed from the most recently completed API call. In essence, it will appear to the API client that each call is taking exactly 500ms (plus/minus network latency). As long as these calls are made in succession in a single thread, no API calls will be rejected.
As soon as the customer throws a second thread at Infusionsoft's server, it will appear to the API client that calls are now taking one second a piece. This is due to the fact that there are twice as many threads competing for the same number of resources. In this circumstance, it is essentially guaranteed that both threads will end up blocked at the same time. This obviously poses a problem, as a customer could easily throw a couple hundred threads at the API and cause a thread starvation issue for the web server.
This is why Infusionsoft has a limit to the number of threads that can be throttled at any given time. Keep in mind, it's not the number of threads that can access the API at any given time � as long as the customer has credits, he can use as many threads as he'd like. It's only when the threads start being throttled that Infusionsoft starts limiting requests. Currently, if there are 3 threads throttled and a 4th attempts to access the API without available credits, the 4th attempt will be rejected with an error message.