Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

SpikeArrest Policy getting triggered without reaching specified threshold

Hi Team, 

We are using a spike arrest policy on our proxy, with a rate limit of 10ps. But we observed that, though the threshold is not reached, we are getting ratelimit exceeded error. I am not expecting this to be accurate like it has to trigger exactly when 10 requests per second is breached, but what we are observing is if we try to access the API for the first time, it is throwing rate limit exceeded error, and this is intermittent. 
Below is the config i am using, 

 

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<SpikeArrest continueOnError="true" enabled="true" name="SA-ProxyRateLimit">
    <DisplayName>SA-ProxyRateLimit</DisplayName>
    <Properties/>
    <Identifier ref="flow.environment.name"/>
    <Rate ref="flow.proxy.ratelimit">10ps</Rate>
    <UseEffectiveCount>true</UseEffectiveCount>
</SpikeArrest>

 

Identifier would be resolved as "apicenter-test" in our case. 

And then, i have tried to reproduce the error, and able to capture the trace the data while issue occurs. 

Below is the data from debug, 

 

 "properties": {
                "property": [
                  {
                    "name": "ratelimit.SA-ProxyRateLimit.total.exceed.count",
                    "value": "0"
                  },
                  {
                    "name": "ratelimit.SA-ProxyRateLimit.identifier",
                    "value": "consumerapi-xxxxxx@@@apicenter-stage@@@proxyname@@@SA-ProxyRateLimit@@@nondistributed@@@apicenter-test@@@10Seconds"
                  },
                  {
                    "name": "ratelimit.SA-ProxyRateLimit.expiry.time",
                    "value": "0"
                  },
                  {
                    "name": "ratelimit.SA-ProxyRateLimit.class.used.count",
                    "value": "0"
                  },
                  {
                    "name": "ratelimit.SA-ProxyRateLimit.is.timeout",
                    "value": "false"
                  },
                  {
                    "name": "ratelimit.SA-ProxyRateLimit.fault.cause",
                    "value": ""
                  },
                  {
                    "name": "ratelimit.SA-ProxyRateLimit.available.count",
                    "value": "9"
                  },
                  {
                    "name": "ratelimit.SA-ProxyRateLimit.datastore.fail.open",
                    "value": "false"
                  },
                  {
                    "name": "ratelimit.SA-ProxyRateLimit.allowed.count",
                    "value": "10"
                  },
                  {
                    "name": "ratelimit.SA-ProxyRateLimit.class.available.count",
                    "value": "0"
                  },
                  {
                    "name": "ratelimit.SA-ProxyRateLimit.fault.name",
                    "value": ""
                  },
                  {
                    "name": "ratelimit.SA-ProxyRateLimit.class.exceed.count",
                    "value": "0"
                  },
                  {
                    "name": "ratelimit.SA-ProxyRateLimit.exceed.count",
                    "value": "0"
                  },
                  {
                    "name": "ratelimit.SA-ProxyRateLimit.class.allowed.count",
                    "value": "0"
                  },
                  {
                    "name": "ratelimit.SA-ProxyRateLimit.class.total.exceed.count",
                    "value": "0"
                  },
                  {
                    "name": "ratelimit.SA-ProxyRateLimit.used.count",
                    "value": "1"
                  },
                  {
                    "name": "ratelimit.SA-ProxyRateLimit.failed",
                    "value": "true"
                  }
                ]

 

I have triggered requests with a delay of more than 2 seconds, still lot of requests failed. 

Also, above sample clearly shows, "ratelimit.SA-ProxyRateLimit.failed" is true, but then if i see the counts, used count is only 1 and available count is 9. 

Not sure, if this is the right way to troubleshoot this, if yes please help if there is any issue with the config. 

Thanks in Advance ! 

0 10 1,408
10 REPLIES 10