# Rate-limiting minutes issue

**URL:** <https://discuss.konghq.com/t/rate-limiting-minutes-issue/1319>\
**Category:** Questions\
**Created:** [June 22, 2018, 3:44pm UTC](https://discuss.konghq.com/t/rate-limiting-minutes-issue/1319 "2018-06-22T15:44:01Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ja8zyjits](https://avatars.discourse-cdn.com/v4/letter/j/958977/32.png) [@ja8zyjits](https://discuss.konghq.com/u/ja8zyjits)\
**Post date:** [June 22, 2018, 3:44pm UTC](https://discuss.konghq.com/t/rate-limiting-minutes-issue/1319/1 "2018-06-22T15:44:01Z")

</div>

Hi,

Iam trying to use the `rate_limiting` plugin.  
`{"minute":2,"policy":"cluster","redis_timeout":2000,"hide_client_headers":false,"hour":5,"limit_by":"consumer","redis_port":6379,"redis_database":0,"fault_tolerant":true},"id":"21c00ada-42e8-475b-872f-48d2e147ba4b","route_id":"e26e8fe7-61b6-461e-a3bb-e9b9e3d3f89b","name":"rate-limiting","enabled":true,"consumer_id":"cd3de8f5-aa0d-4424-810b-66173af5c9f3"}`

but here the `minutes` section is not working properly  
eg: i have set rate-limit for minutes=2 and hour=5

> step1: call the api =\> works  
> step2: call the api within same minute =\> works  
> step3: call the api again in same minute =\> rate\_limit (success)  
> step5: call the api next minute=\>works  
> step5: call the api in the same minute=\>works  
> (issue)step6: call the api in the same minute=\>works(it should have rate\_limited here since it breached 2/minute rate\_limit)  
> step7: call the api next minute=\>rate\_limit

nginx log:

```
xxx.xxx.xxx.xxx - - [22/Jun/2018:15:23:29 +0000] "GET /api_page?apikey=<key>&name=Sachin_Tendulkar HTTP/1.1" 200 5216 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/60.0"

xxx.xxx.xxx.xxx - - [22/Jun/2018:15:23:41 +0000] "GET /api_page?apikey=<key>&name=Sachin_Tendulkar HTTP/1.1" 200 5216 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/60.0"

xxx.xxx.xxx.xxx - - [22/Jun/2018:15:23:50 +0000] "GET /api_page?apikey=<key>&name=Sachin_Tendulkar HTTP/1.1" 429 49 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/60.0"

xxx.xxx.xxx.xxx - - [22/Jun/2018:15:28:53 +0000] "GET /api_page?apikey=<key>&name=Sachin_Tendulkar HTTP/1.1" 200 5216 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/60.0"

xxx.xxx.xxx.xxx - - [22/Jun/2018:15:29:00 +0000] "GET /api_page?apikey=<key>&name=Sachin_Tendulkar HTTP/1.1" 200 5216 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/60.0"

xxx.xxx.xxx.xxx - - [22/Jun/2018:15:29:09 +0000] "GET /api_page?apikey=<key>&name=Sachin_Tendulkar HTTP/1.1" 200 5216 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/60.0"

xxx.xxx.xxx.xxx - - [22/Jun/2018:15:29:17 +0000] "GET /api_page?apikey=<key>&name=Sachin_Tendulkar HTTP/1.1" 429 49 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/60.0"

```

If you check the time of last 4 requests it shows requests within same minute.  
Is this the intended behavior?  
I was expecting it to work strictly 2/minute and 5/hour

Thanks

---

<div class="post-metadata">

**Author:** ![kikito](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.konghq.com/kikito/32/15_2.png) [@kikito](https://discuss.konghq.com/u/kikito)\
**Post date:** [August 20, 2018, 12:10pm UTC](https://discuss.konghq.com/t/rate-limiting-minutes-issue/1319/2 "2018-08-20T12:10:38Z")

</div>

Hi,

The rate limiting occurs by “dividing time in periods”, not by “counting backwards from the last request to see how many requests have happened”.

In your example, the first 3 requests where done on minute 23, the next request was done on minute 28, and the last 3 requests where done on minute 29. You are seeing the expected behaviour.
