API Based Throttling (policy-api-based-throttling type)
Parameters
Parameter | Type | Required | Default Value | Description | Rules |
---|---|---|---|---|---|
name | String | Yes | - | Policy name | API must be unique in Proxy |
targetVariableForIdentity | VariableDTO | No | - | Identity variable to be used for Throttling tracking | Maximum number of requests allowed in the specified time interval |
messageCountForInterval | Integer | Yes | - | ||
throttlingInterval | EnumThrottleTimeInterval | Yes | - | Throttling time interval | - |
cacheConnectionTimeoutInSeconds | Integer | No | 3 | Cache connection timeout (seconds) | Must be greater than 0 |
cacheErrorHandlingType | Enum | No | FAIL | Action to be taken in case of cache error | - |
detailList | Array | No | - | Specific throttling limits are defined for each destination (e.g. user, IP) | One or more throttling limits are defined. |
throttlingInterval values
Value | Description |
---|---|
ONE_SECOND | Request limit per second |
ONE_MINUTE | Request limit per minute |
cacheErrorHandlingType values
Value | Description |
---|---|
FAIL | Deny request in case of cache error |
CONTINUE | Allow request in case of cache error |
Values that can be added to detailList Array
Paremeter | Type | Required | Default Value | Description | Rules |
---|---|---|---|---|---|
targetValue | String | No | - | Target Value | - |
regexExpression | Bool | No | false | Regex Expression | - |
messageCountForInterval | Integer | No | - | Number of Messages for Throttling Time Interval | Must be greater than 0 |
intervalPeriodLength | Integer | No | - | Throttling Time Interval | Must be greater than 0 |
throttlingInterval | Enum | No | - | Throttling Time Unit | - |
Example JSON Structures
1. IP Based Secondary Throttling
{
"operationMetadata" : {
"targetScope" : "ALL",
"targetPipeline" : "REQUEST",
"deploy" : true,
"deployTargetEnvironmentNameList": [
"test", "prod"
],
"order" : 1
},
"policy" : {
"type" : "policy-api-based-throttling",
"name" : "SaniyelikIpThrottling",
"messageCountForInterval" : 10,
"throttlingInterval" : "ONE_SECOND",
"cacheConnectionTimeoutInSeconds" : 5,
"cacheErrorHandlingType" : "FAIL",
"targetVariableForIdentity" : {
"name" : "clientIp",
"type" : "CONTEXT_VALUES",
"contextValue" : "REQUEST_REMOTE_ADDRESS",
"description" : "İstemci IP adresi"
}
}
}
CODE
2. IP Based Secondly Throttling + User IP Based Secondly and Minute Quota
{
"operationMetadata" : {
"targetScope" : "ALL",
"targetPipeline" : "REQUEST",
"deploy" : true,
"deployTargetEnvironmentNameList": [
"test", "prod"
],
"order" : 1
},
"policy" : {
"type" : "policy-api-based-throttling",
"name" : "SaniyelikIpThrottling",
"messageCountForInterval" : 10,
"throttlingInterval" : "ONE_SECOND",
"cacheConnectionTimeoutInSeconds" : 5,
"cacheErrorHandlingType" : "FAIL",
"targetVariableForIdentity" : {
"name" : "clientIp",
"type" : "CONTEXT_VALUES",
"contextValue" : "REQUEST_REMOTE_ADDRESS",
"description" : "İstemci IP adresi"
},
"detailList": [
{
"targetValue": "<IP>",
"regexExpression": false,
"messageCountForInterval": 20,
"intervalPeriodLength": 1,
"quotaInterval": "ONE_SECOND"
},
{
"targetValue": "10.0.0.*",
"regexExpression": true,
"messageCountForInterval": 5,
"intervalPeriodLength": 2,
"quotaInterval": "ONE_MINUTE"
}
]
}
}
CODE
3. Minute Based Throttling
{
"operationMetadata" : {
"targetScope" : "ENDPOINT",
"targetEndpoint" : "/api/v1/transactions",
"targetEndpointHTTPMethod" : "POST",
"targetPipeline" : "REQUEST",
"deploy" : true,
"deployTargetEnvironmentNameList": [
"test", "prod"
],
"order" : 1
},
"policy" : {
"type" : "policy-api-based-throttling",
"name" : "DakikalikApiKeyThrottling",
"messageCountForInterval" : 60,
"throttlingInterval" : "ONE_MINUTE",
"cacheConnectionTimeoutInSeconds" : 3,
"cacheErrorHandlingType" : "PASS",
"targetVariableForIdentity" : {
"name" : "apiKey",
"type" : "HEADER",
"headerName" : "X-API-KEY",
"description" : "API Anahtarı"
}
}
}
CODE