About customer and the performance


#1

Let’s say, I want to limit all user who visit my site (except register page) 5 times per second.

Suppose, there is a new user come to my site. My site register for the user, and then though the admin API to create a user in kong, and at last add a restriction for the user thought the admin API? (This is somthing like specific user)
Another way to achieve this is: every time user in kong, using a costom plugin to query (though my site) weather the user achieve the limitation.

The first solution is more complex, the second solution is to bad because the limit logic is not in doing in Kong. Is there anthoer better way to doing this?

And what’s the performance of the Kong(simple proxy request with no plugin)? Is there any page to show the statistic?


#2

You can apply rate-limiting plugins for all-users as:

  1. global plugin
  2. plugin added to service
  3. plugin added to route

Then you can create Kong consumer (the specific user), and after that add another overriding rate-limiting plugin to that consumer:
4. plugin added to consumer

Of course now Kong needs to somehow know that request came from a specific consumer or not. So for that you need authentication plugin. You can set the authentication plugin to allow anonymous traffic too, by setting config.anonymous. Then one option is to add

  1. rate-limiting plugin for specific consumer
  2. rate-limiting plugin for anonymous consumer (e.g. that 5 times per second)

#3

Thanks a lot. That help me.