Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kong rate limiting concurrent problem #2629

Closed
qingziguanjun opened this issue Jun 16, 2017 · 3 comments
Closed

Kong rate limiting concurrent problem #2629

qingziguanjun opened this issue Jun 16, 2017 · 3 comments

Comments

@qingziguanjun
Copy link

qingziguanjun commented Jun 16, 2017

For kong 0.10.2, i add rate limiting plugin for my api:
curl -X POST http://10.10.11.152:8001/apis/bjlife615/plugins
--data "name=rate-limiting"
--data "config.second=5"
--data "config.minute=100"

i use java code call the proxy url:
final String url = "http://kong.d.internetware.cn/bjlife/vericode615?apikey=sy1"; for(int i=0;i<10;i++){ System.out.println(HttpTool.sendGet(url, null)); }

i will get error:
{"message":"API rate limit exceeded"}

but if i use concurrent code:
for(int i=0;i<10;i++){ new Thread(){ public void run() { System.out.println(HttpTool.sendGet(url, null)); }; }.start(); }
i will never get rate limit error,how can i fix it?

@p0pr0ck5
Copy link
Contributor

@qingziguanjun by default, the cluster policy is used to track usage data across the Kong cluster, but in its current design, it can be susceptible to race conditions in benchmark environments such as this. If you run just a single Kong node, try setting the config.policy value to local on the plugin config.

@qingziguanjun
Copy link
Author

qingziguanjun commented Jun 19, 2017

i am using just a single Kong node,so
if i set like this:
curl -X POST http://10.10.11.152:8001/apis/bjlife615/plugins
--data "name=rate-limiting"
--data "config.second=5"
--data "config.minute=100" --data " config.policy=local"

Then there is no rate-limit effort,i will never get such error:
{"message":"API rate limit exceeded"}

@p0pr0ck5
Copy link
Contributor

Hi,

In the future please avoid cross posting to both the mailing list and GH issues. Since there is a discussion going on here (https://groups.google.com/forum/#!topic/konglayer/JRpoNnDuEZ8) I will close this. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants