Hi,
We have been observing rate limit tracking is not happening as per the policy set for all our API keys in a stage deployment of Tyk. We are only seeing it in one of the 2 stage Tyk environments running the same version of gateway and dashboard. Please find the JSON of a sample policy and key for an API for which we are seeing this.
Policy -
{
“_id” : ObjectId(“58983b666971d10001e8c51d”),
“org_id” : “xxxxxxxxxxxxxx”,
“rate” : 20,
“per” : 60,
“quota_max” : NumberLong(-1),
“quota_renewal_rate” : NumberLong(60),
“access_rights” : {
“xxxxxxxxxxxxxx” : {
“apiname” : “httpbin”,
“apiid” : “xxxxxxxxxxxxxx”,
“versions” : [
“Default”
],
“allowed_urls” : []
}
},
“hmac_enabled” : false,
“active” : true,
“name” : “TestPolicy”,
“is_inactive” : false,
“date_created” : Date(-62135596800000),
“tags” : [
“testpolicy”
],
“key_expires_in” : NumberLong(0),
“partitions” : {
“quota” : true,
“rate_limit” : true,
“acl” : true
},
“last_updated” : “1497848209”
}
API key value in Redis -
{
“last_check”: 0,
“allowance”: 20,
“rate”: 20,
“per”: 60,
“expires”: 0,
“quota_max”: -1,
“quota_renews”: 1497848223,
“quota_remaining”: -1,
“quota_renewal_rate”: 60,
“access_rights”: {
“xxxxxxxxxxxxx”: {
“api_name”: “httpbin”,
“api_id”: “xxxxxxxxxxxxx”,
“versions”: [
“Default”
],
“allowed_urls”: []
}
},
“org_id”: “xxxxxxxxxxxxx”,
“oauth_client_id”: “”,
“oauth_keys”: null,
“basic_auth_data”: {
“password”: “”,
“hash_type”: “”
},
“jwt_data”: {
“secret”: “”
},
“hmac_enabled”: false,
“hmac_string”: “”,
“is_inactive”: false,
“apply_policy_id”: “58983b666971d10001e8c51d”,
“data_expires”: 0,
“monitor”: {
“trigger_limits”: null
},
“enable_detail_recording”: false,
“meta_data”: {
“Contact”: "[email protected]"
},
“tags”: [
“testpolicy”
],
“alias”: "[email protected]",
“last_updated”: “1497848209”,
“id_extractor_deadline”: 0,
“session_lifetime”: 0
}
In this example key-policy for an API, rate limit is set to 20 per 60 seconds. However, we see that on the 10th request, we see 429(Rate limit exceeded) error. Similarly, if rate is set to 5, the 3rd request onwards returns 429. Only 1 less that half the number of requests set in the rate limit for the key is allowed. This is seen for all APIs in that Tyk environment. Has anyone observed this before? If yes, please suggest a solution for this issue. Thanks in advance.