forked from docs/doc-exports
Reviewed-by: Hasko, Vladimir <vladimir.hasko@t-systems.com> Co-authored-by: Chen, Junjie <chenjunjie@huawei.com> Co-committed-by: Chen, Junjie <chenjunjie@huawei.com>
165 lines
17 KiB
HTML
165 lines
17 KiB
HTML
<a name="apig-ug-0015"></a><a name="apig-ug-0015"></a>
|
|
|
|
<h1 class="topictitle1">Request Throttling Plug-in</h1>
|
|
<div id="body0000001226605671"><p id="apig-ug-0015__p6738143512115">The request throttling plug-in limits the number of times an API can be called within a specific time period. It supports parameter-based, basic, and excluded throttling.</p>
|
|
<div class="note" id="apig-ug-0015__en-us_topic_0000001151387425_note4473101013417"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="apig-ug-0015__en-us_topic_0000001151387425_p8473610747">If your gateway does not support the request throttling plug-in, contact customer service to upgrade the gateway.</p>
|
|
</div></div>
|
|
<ul id="apig-ug-0015__ul763017557225"><li id="apig-ug-0015__li1563095572215">Basic throttling<p id="apig-ug-0015__p1221272216383"><a name="apig-ug-0015__li1563095572215"></a><a name="li1563095572215"></a>Throttle requests by API, user, app, or source IP address. This function is equivalent to a <a href="apig-en-ug-180307028.html">request throttling policy</a> but is incompatible with it.</p>
|
|
</li><li id="apig-ug-0015__li85608259385">Parameter-based throttling<p id="apig-ug-0015__p34121732182916"><a name="apig-ug-0015__li85608259385"></a><a name="li85608259385"></a>Throttle requests based on headers, path parameters, methods, query strings, or system variables.</p>
|
|
</li><li id="apig-ug-0015__li89482424230">Excluded throttling<p id="apig-ug-0015__p1714144362318"><a name="apig-ug-0015__li89482424230"></a><a name="li89482424230"></a>Throttle requests based on specific apps or tenants.</p>
|
|
</li></ul>
|
|
<div class="section" id="apig-ug-0015__section101209654414"><h4 class="sectiontitle">Constraints</h4><ul id="apig-ug-0015__ul7598162513916"><li id="apig-ug-0015__li359811253395">A request throttling policy becomes invalid if a request throttling plug-in is bound to the same API as the policy.</li><li id="apig-ug-0015__li1259812520397">You can define a maximum of 100 parameter rules.</li><li id="apig-ug-0015__li241410405113">The plug-in content cannot exceed 65,535 characters.</li></ul>
|
|
</div>
|
|
<div class="section" id="apig-ug-0015__section1355043524417"><h4 class="sectiontitle">Configuration Parameters</h4>
|
|
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="apig-ug-0015__table3471155116443" frame="border" border="1" rules="all"><caption><b>Table 1 </b>Configuration parameters</caption><thead align="left"><tr id="apig-ug-0015__row9472135114414"><th align="left" class="cellrowborder" valign="top" width="30%" id="mcps1.3.5.2.2.3.1.1"><p id="apig-ug-0015__p14472751124418">Parameter</p>
|
|
</th>
|
|
<th align="left" class="cellrowborder" valign="top" width="70%" id="mcps1.3.5.2.2.3.1.2"><p id="apig-ug-0015__p547215516449">Description</p>
|
|
</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody><tr id="apig-ug-0015__row1447295112441"><td class="cellrowborder" valign="top" width="30%" headers="mcps1.3.5.2.2.3.1.1 "><p id="apig-ug-0015__p12472251184412">Policy Type</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="70%" headers="mcps1.3.5.2.2.3.1.2 "><ul id="apig-ug-0015__ul11655132184813"><li id="apig-ug-0015__li0655173254815">API-specific<p id="apig-ug-0015__p8985353175919"><a name="apig-ug-0015__li0655173254815"></a><a name="li0655173254815"></a>Monitor and control the requests of a single API.</p>
|
|
</li><li id="apig-ug-0015__li9655232104811">API-sharing<p id="apig-ug-0015__p529956904"><a name="apig-ug-0015__li9655232104811"></a><a name="li9655232104811"></a>Monitor and control the total requests of all APIs bound with the plug-in.</p>
|
|
</li></ul>
|
|
</td>
|
|
</tr>
|
|
<tr id="apig-ug-0015__row1247205118447"><td class="cellrowborder" valign="top" width="30%" headers="mcps1.3.5.2.2.3.1.1 "><p id="apig-ug-0015__p14181846135617">Period</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="70%" headers="mcps1.3.5.2.2.3.1.2 "><p id="apig-ug-0015__p1818846175612">For how long you want to limit the number of API requests.</p>
|
|
<ul id="apig-ug-0015__ul318346145616"><li id="apig-ug-0015__li17187465567"><strong id="apig-ug-0015__b123371510193419">Max. API Requests</strong>: Limit the maximum number of times an API can be called within a specific time period.</li><li id="apig-ug-0015__li6181146115619"><strong id="apig-ug-0015__b1119114534423">Max. User Requests</strong>: Limit the maximum number of times an API can be called by a user within a specific time period.</li><li id="apig-ug-0015__li2189467563"><strong id="apig-ug-0015__b1091317153432">Max. App Requests</strong>: Limit the maximum number of times an API can be called by an app within a specific time period.</li><li id="apig-ug-0015__li8184467563"><strong id="apig-ug-0015__b27522264319">Max. IP Address Requests</strong>: Limit the maximum number of times an API can be called by an IP address within a specific time period.</li></ul>
|
|
</td>
|
|
</tr>
|
|
<tr id="apig-ug-0015__row15472155174419"><td class="cellrowborder" valign="top" width="30%" headers="mcps1.3.5.2.2.3.1.1 "><p id="apig-ug-0015__p85682272014">Max. API Requests</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="70%" headers="mcps1.3.5.2.2.3.1.2 "><p id="apig-ug-0015__p0568327311">The maximum number of times each bound API can be called within the specified period.</p>
|
|
<p id="apig-ug-0015__p135683271215">This parameter must be used together with <strong id="apig-ug-0015__b37631113124717">Period</strong>.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="apig-ug-0015__row16472151184410"><td class="cellrowborder" valign="top" width="30%" headers="mcps1.3.5.2.2.3.1.1 "><p id="apig-ug-0015__p6568927812">Max. User Requests</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="70%" headers="mcps1.3.5.2.2.3.1.2 "><p id="apig-ug-0015__p297455420281">The maximum number of times each bound API can be called by a user within the specified period. For APIs with IAM authentication, the throttling is based on a project ID; for APIs with app authentication, the throttling is based on an account ID. For details about account IDs and project IDs, see the description about <strong id="apig-ug-0015__b19952175613136">Excluded Tenants</strong> in this table.</p>
|
|
<ul id="apig-ug-0015__ul8568192718112"><li id="apig-ug-0015__li458558142814">The value of this parameter cannot exceed that of <strong id="apig-ug-0015__b84111828155514">Max. API Requests</strong>.</li><li id="apig-ug-0015__li1356882712112">This parameter must be used together with <strong id="apig-ug-0015__b54082359557">Period</strong>.</li><li id="apig-ug-0015__li956892711113">If there are many users under your account that access an API, the request throttling limits of the API will apply to all these users.</li></ul>
|
|
</td>
|
|
</tr>
|
|
<tr id="apig-ug-0015__row647235154417"><td class="cellrowborder" valign="top" width="30%" headers="mcps1.3.5.2.2.3.1.1 "><p id="apig-ug-0015__p9568927814">Max. App Requests</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="70%" headers="mcps1.3.5.2.2.3.1.2 "><p id="apig-ug-0015__p1156815271114">The maximum number of times each bound API can be called by an app within the specified period. This limit only applies to APIs that are accessed through app authentication.</p>
|
|
<ul id="apig-ug-0015__ul1256819271310"><li id="apig-ug-0015__li1156810278112">The value of this parameter cannot exceed that of <strong id="apig-ug-0015__b594343413569">Max. User Requests</strong>.</li><li id="apig-ug-0015__li956842711116">This parameter must be used together with <strong id="apig-ug-0015__b12887139145617">Period</strong>.</li></ul>
|
|
</td>
|
|
</tr>
|
|
<tr id="apig-ug-0015__row126917271656"><td class="cellrowborder" valign="top" width="30%" headers="mcps1.3.5.2.2.3.1.1 "><p id="apig-ug-0015__p1356962717118">Max. IP Address Requests</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="70%" headers="mcps1.3.5.2.2.3.1.2 "><p id="apig-ug-0015__p18569927219">The maximum number of times each bound API can be called by an IP address within the specified period.</p>
|
|
<ul id="apig-ug-0015__ul20569227315"><li id="apig-ug-0015__li1156912713117">The value of this parameter cannot exceed that of <strong id="apig-ug-0015__b081113418558">Max. API Requests</strong>.</li><li id="apig-ug-0015__li2569427612">This parameter must be used together with <strong id="apig-ug-0015__b1039111015713">Period</strong>.</li></ul>
|
|
</td>
|
|
</tr>
|
|
<tr id="apig-ug-0015__row07610411162"><td class="cellrowborder" valign="top" width="30%" headers="mcps1.3.5.2.2.3.1.1 "><p id="apig-ug-0015__p1876184118618">Parameter-based Throttling</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="70%" headers="mcps1.3.5.2.2.3.1.2 "><p id="apig-ug-0015__p8513122521017">Enable or disable parameter-based throttling. After this function is enabled, API requests are throttled based on specified parameters.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="apig-ug-0015__row911017210714"><td class="cellrowborder" valign="top" width="30%" headers="mcps1.3.5.2.2.3.1.1 "><p id="apig-ug-0015__p1111062112715">Parameters</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="70%" headers="mcps1.3.5.2.2.3.1.2 "><p id="apig-ug-0015__p1243415620139">Define parameters for throttling rules.</p>
|
|
<ul id="apig-ug-0015__ul1545581818423"><li id="apig-ug-0015__li144551118134215"><strong id="apig-ug-0015__b1390735616595">Parameter Location</strong>: the location of a parameter to be used in a rule.<ul id="apig-ug-0015__ul1133612855719"><li id="apig-ug-0015__li71987356566"><strong id="apig-ug-0015__b1395562411212">path</strong>: API request URI. This parameter is configured by default.</li><li id="apig-ug-0015__li3738543185610"><strong id="apig-ug-0015__b04740184417">method</strong>: API request method. This parameter is configured by default.</li><li id="apig-ug-0015__li7334105014568"><strong id="apig-ug-0015__b15233210457">Header</strong>: the value of the first HTTP header with the parameter name you set.</li><li id="apig-ug-0015__li1463135745617"><strong id="apig-ug-0015__b1131312173711">Query</strong>: the value of the first query string with the parameter name you set.</li><li id="apig-ug-0015__li126361212155718"><strong id="apig-ug-0015__b20640114516817">System</strong>: a system parameter.</li></ul>
|
|
</li><li id="apig-ug-0015__li145581815427"><strong id="apig-ug-0015__b2466132210911">Parameter Name</strong>: the name of a parameter to match the specified value in a rule.</li></ul>
|
|
</td>
|
|
</tr>
|
|
<tr id="apig-ug-0015__row1145715288710"><td class="cellrowborder" valign="top" width="30%" headers="mcps1.3.5.2.2.3.1.1 "><p id="apig-ug-0015__p44579284713">Rules</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="70%" headers="mcps1.3.5.2.2.3.1.2 "><p id="apig-ug-0015__p1122316567245">Define throttling rules. A rule consists of conditions, an API request throttling limit, and a period.</p>
|
|
<p id="apig-ug-0015__p18362134662117">To add more rules, click <strong id="apig-ug-0015__b16239124316165">Add Rule</strong>.</p>
|
|
<ul id="apig-ug-0015__ul5362182433415"><li id="apig-ug-0015__li161681338183411">Conditions<p id="apig-ug-0015__p124231048133710"><a name="apig-ug-0015__li161681338183411"></a><a name="li161681338183411"></a>Click <span><img id="apig-ug-0015__image1867194123412" src="en-us_image_0000001181165262.png"></span> to set condition expressions. To set an expression, select a parameter and operator, and enter a value.</p>
|
|
<ul id="apig-ug-0015__ul1350815083411"><li id="apig-ug-0015__li143857383379"><strong id="apig-ug-0015__b7543195162713">=</strong>: equal to</li><li id="apig-ug-0015__li73851138133714"><strong id="apig-ug-0015__b15816191192713">!=</strong>: not equal to</li><li id="apig-ug-0015__li5385193803712"><strong id="apig-ug-0015__b1882315225275">pattern</strong>: regular expression</li><li id="apig-ug-0015__li1065918569375"><strong id="apig-ug-0015__b430355713270">enum</strong>: enumerated values. Separate multiple values with commas (,).</li></ul>
|
|
</li><li id="apig-ug-0015__li13363162419348">Max. API Requests<p id="apig-ug-0015__p161385147162"><a name="apig-ug-0015__li13363162419348"></a><a name="li13363162419348"></a>The maximum number of times that an API can be called within a specific time period.</p>
|
|
</li><li id="apig-ug-0015__li73631424143414">Period<p id="apig-ug-0015__p677642018386"><a name="apig-ug-0015__li73631424143414"></a><a name="li73631424143414"></a>A period of time that will apply with the throttling limit you set. If not specified, the period set in the <strong id="apig-ug-0015__b44804523510">Police Details</strong> area will be used.</p>
|
|
</li></ul>
|
|
<p id="apig-ug-0015__p29603513151">For example, configure parameter-based throttling as follows: add the <strong id="apig-ug-0015__b999173294116">Host</strong> parameter and specify the location as <strong id="apig-ug-0015__b2030317274217">Header</strong>; add the condition <strong id="apig-ug-0015__b14839143411427">Host = www.abc.com</strong>, and set the throttling limit to <strong id="apig-ug-0015__b4333195920423">10</strong> and the period to 60s. For APIs whose <strong id="apig-ug-0015__b77861114143120">Host</strong> parameter in the request header is equal to <strong id="apig-ug-0015__b1278601483110">www.abc.com</strong>, they cannot be called again once called 10 times in 60s.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="apig-ug-0015__row62065283125"><td class="cellrowborder" valign="top" width="30%" headers="mcps1.3.5.2.2.3.1.1 "><p id="apig-ug-0015__p141039211999">Excluded Throttling</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="70%" headers="mcps1.3.5.2.2.3.1.2 "><p id="apig-ug-0015__p17207102817126">Enable or disable excluded throttling. After this function is enabled, the throttling limits for excluded tenants and apps override the <strong id="apig-ug-0015__b1265421085216">Max. User Requests</strong> and <strong id="apig-ug-0015__b5558135522">Max. App Requests</strong> in the <strong id="apig-ug-0015__b11656131518529">Basic Throttling</strong> area.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="apig-ug-0015__row1759173119125"><td class="cellrowborder" valign="top" width="30%" headers="mcps1.3.5.2.2.3.1.1 "><p id="apig-ug-0015__p1175943110126">Excluded Tenants</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="70%" headers="mcps1.3.5.2.2.3.1.2 "><p id="apig-ug-0015__p1875953111124"><strong id="apig-ug-0015__b19437725124614">Tenant ID</strong>: an account ID or project ID.</p>
|
|
<ul id="apig-ug-0015__ul193068592277"><li id="apig-ug-0015__li18306175919278">Specify a project ID for an API with app authentication. For details, see "Obtaining a Project ID" in the <em id="apig-ug-0015__i247015519293">API Gateway API Reference</em>.</li><li id="apig-ug-0015__li1230695992710">Specify an account ID (not IAM user ID) for an API with IAM authentication. For details, see "Obtaining an Account Name and Account ID" in the <em id="apig-ug-0015__i719114547290">API Gateway API Reference</em>.</li></ul>
|
|
<p id="apig-ug-0015__p1036010155406"><strong id="apig-ug-0015__b19178184064610">Threshold</strong>: the maximum number of times that a specific tenant can access an API within the specified period. The threshold cannot exceed the value of <strong id="apig-ug-0015__b067910492309">Max. API Requests</strong> in the <strong id="apig-ug-0015__b1679134917306">Basic Throttling</strong> area.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="apig-ug-0015__row18683163411212"><td class="cellrowborder" valign="top" width="30%" headers="mcps1.3.5.2.2.3.1.1 "><p id="apig-ug-0015__p36837349123">Excluded Apps</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="70%" headers="mcps1.3.5.2.2.3.1.2 "><p id="apig-ug-0015__p112814113249">Select an app, and specify the maximum number of times that the app can access an API within the specified period. The threshold cannot exceed the value of <strong id="apig-ug-0015__b141911448491">Max. API Requests</strong> in the <strong id="apig-ug-0015__b1239993916305">Basic Throttling</strong> area.</p>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
<div class="section" id="apig-ug-0015__section1798116426248"><h4 class="sectiontitle">Example Script</h4><pre class="screen" id="apig-ug-0015__screen16295122414222">{
|
|
"scope": "basic",
|
|
"default_interval": 60,
|
|
"default_time_unit": "second",
|
|
"api_limit": 100,
|
|
"app_limit": 50,
|
|
"user_limit": 50,
|
|
"ip_limit": 20,
|
|
"specials": [
|
|
{
|
|
"type": "app",
|
|
"policies": [
|
|
{
|
|
"key": "2e421d76dc6c4c75941511ccf654e368",
|
|
"limit": 10
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"type": "user",
|
|
"policies": [
|
|
{
|
|
"key": "878f1b87f71c40a7a15db0998f358bb9",
|
|
"limit": 10
|
|
}
|
|
]
|
|
}
|
|
],
|
|
"parameters": [
|
|
{
|
|
"type": "path",
|
|
"name": "reqPath",
|
|
"value": "reqPath"
|
|
},
|
|
{
|
|
"type": "method",
|
|
"name": "method",
|
|
"value": "method"
|
|
},
|
|
{
|
|
"type": "header",
|
|
"name": "Host",
|
|
"value": "Host"
|
|
}
|
|
],
|
|
"rules": [
|
|
{
|
|
"match_regex": "[\"Host\",\"==\",\"www.abc.com\"]",
|
|
"rule_name": "rule-jlce",
|
|
"time_unit": "second",
|
|
"interval": 0,
|
|
"limit": 5
|
|
}
|
|
]
|
|
}</pre>
|
|
</div>
|
|
</div>
|
|
<div>
|
|
<div class="familylinks">
|
|
<div class="parentlink"><strong>Parent topic:</strong> <a href="apig-ug-0001.html">Plug-ins</a></div>
|
|
</div>
|
|
</div>
|
|
|