Jacob Wallace
Jacob Wallace

Reputation: 927

Can Kong rate limit per endpoint?

I can configure Kong's rate limiting plugin so it enforces limits on each endpoint in a given API like this:

$ curl -X POST http://kong:8001/apis/{api}/plugins \
    --data "name=rate-limiting" \
    --data "config.second=5"

However, I'd like to configure different rate limits per endpoint. For example, I'd like to allow:

Is this possible with Kong? I see an open issue related to this, but are there any workarounds?

Upvotes: 2

Views: 4087

Answers (3)

John Paul
John Paul

Reputation: 44

Until Kong .13, this was not possible. However, in Kong .13 the API object has been broken into 2 parts, routes and services.

Using these tools, you should be able to apply different plugins for different endpoints in your API.

Upvotes: 1

Shaleen
Shaleen

Reputation: 909

Kong cannot work on IP mode I believe. But to over come that you have combination of authentication and rate limiting. With the combination of this you can say

API 1 - limited to 5 request/second for consumer 1
API 1 (again) - limited to 10 request/second for consumer 2
API 2 - limited to 25 request/second from consumer 1

To achieve this you need to enable authentication in the kong for the APIs you want to control and then assign the rates for each consumer/api.

This will give you benefit of controlling the request from consumers so that they will not be able to do extra request from multiple IPs. (if you want)

Upvotes: 0

Cooper
Cooper

Reputation: 866

Could you make each endpoint into a Kong API, then apply rate-limiting per-API?

Upvotes: 1

Related Questions