forked from Continumity/Infusionsoft-API-Documentation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rate_limiting.html
123 lines (118 loc) · 6.87 KB
/
rate_limiting.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
<!DOCTYPE html>
<html>
<head>
<title>API Requests - Infusionsoft API</title>
<link rel="stylesheet" href="bootstrap/css/bootstrap.min.css"/>
<link rel="stylesheet" href="bootstrap/css/bootstrap-extension.css"/>
<script src="bootstrap/js/bootstrap.min.js" type="text/javascript"></script>
<link href="google-code-prettify/src/prettify.css" type="text/css" rel="stylesheet"/>
<script type="text/javascript" src="google-code-prettify/src/prettify.js"></script>
</head>
<body onload="prettyPrint()">
<div class="container">
<img src="bootstrap/img/logo.png">
<hr>
<div class="row">
<div class="span3 sidebar">
<div class="well" style="padding: 8px 0;">
<ul class="nav nav-list">
<li class="nav-header">Overview</li>
<li><a href="index.html">Introduction</a></li>
<li><a href="request.html">Requests</a></li>
<li><a href="response.html">Responses</a></li>
<li><a href="error.html">Errors</a></li>
<li><a href="api_console.html">API Console</a></li>
<li class="active"><a href="rate_limiting.html">API Rate Limiting</a></li>
<li><a href="changelog.html">Changelog</a></li>
<li class="nav-header">Services</li>
<li><a href="affiliateservice.html">AffiliateService</a></li>
<li><a href="affiliateprogramservice.html">AffiliateProgramService</a></li>
<li><a href="contactservice.html">ContactService</a></li>
<li><a href="dataservice.html">DataService</a></li>
<li><a href="discountservice.html">DiscountService</a></li>
<li><a href="emailservice.html">EmailService</a></li>
<li><a href="fileservice.html">FileService</a></li>
<li><a href="funnelservice.html">FunnelService</a></li>
<li><a href="invoiceservice.html">InvoiceService</a></li>
<li><a href="orderservice.html">OrderService</a></li>
<li><a href="productservice.html">ProductService</a></li>
<li><a href="searchservice.html">SearchService</a></li>
<li><a href="shippingservice.html">ShippingService</a></li>
<li><a href="webformservice.html">WebFormService</a></li>
</ul>
</div>
</div>
<div class="span9">
<div class="page-header">
<h1>API Rate Limiting
<small>how the Infusionsoft rate limiting works</small>
</h1>
</div>
<p>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:</p>
<table class="table table-striped">
<thead>
<tr>
<th>Paramater</th>
<th>Default Value</th>
</tr>
</thead>
<tbody>
<tr>
<td>Milliseconds it takes for a customer to earn 1 credit</td>
<td>500ms</td>
</tr>
<tr>
<td>Maximum number of credits that can be accumulated</td>
<td>10000</td>
</tr>
<tr>
<td>Maximum number of threads that can be throttled at any given time</td>
<td>4</td>
</tr>
</tbody>
</table>
<h4>Bullets</h4>
<ul>
<li>Applications start with 0 credits</li>
<li>For every 500ms with no API traffic, the application accumulates 1 credit</li>
<li>Each API request costs the application 1 credit</li>
</ul>
<h4>Detailed Explanation</h4>
<p>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.</p>
<p>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).</p>
<p>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.</p>
<p>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.</p>
<p>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.</p>
</div>
</div>
</div>
</body>
</html>