Kong / kong

🦍 The Cloud-Native API Gateway and AI Gateway.
https://konghq.com/install/#kong-community
Apache License 2.0
39.05k stars 4.79k forks source link

The response is very slow when I add a plugin in the version of 0.10.2 #2504

Closed ssholder closed 7 years ago

ssholder commented 7 years ago

Summary

I have upgraded Kong to the version of 0.10.2. When I add a plugin to my Api, it will return the response data about 40 senconds. It's very slow for me.

Steps To Reproduce

When I add the plugin like apiName: test1 name: key-auth

Then add the plugin by curl: curl -X POST http://localhost:8001/apis/test1/plugins \ --data "name=key-auth" So I will get the response data: {"api_id":"83378633-1f68-4789-9599-c260dc23bafd","id":"467d37ed-c03b-49f7-8754-44beafb52868","created_at":1494152015000,"enabled":true,"name":"key-auth","config":{"hide_credentials":false,"key_names":["apikey"],"anonymous":""}}

But the return time is about 40 seconds or more, it's too slow. When I add the plugin in other versions, the return time is very short. How to shorten the return time in the version of 0.10.2, make some modifications to the configuration or waiting for the next version which will fix this bug? Thank you very much

p0pr0ck5 commented 7 years ago

@ssholder do you see this behavior on every single request, or just the first time you attempt to consume this API?

ssholder commented 7 years ago

@p0pr0ck5 For all Apis when I add the plugin, the return time for response data is too slow.

p0pr0ck5 commented 7 years ago

Do you see this with just the key-auth plugin, or all plugins?

There's nothing in Kong 0.10.2 that should cause such a massive delay; sounds like there is a problem elsewhere in your environment, such as a poor/timing out connection to postgres/cassandra. Do you see anything in the error logs of note (default location: /usr/local/kong/logs/error.log)?

ssholder commented 7 years ago

@p0pr0ck5 Thank you for your help. 1) I check the error logs when I add a plugin, then I get the error information:

 [error] 7390#0: *157 [lua] reports.lua:49: log(): [reports] could not set peer name for UDP socket: [toip() name lookup failed]: failed to receive reply from UDP server 10.135.1.21:53: timeout, client: 127.0.0.1, server: kong_admin, request: "POST /apis/test1/plugins HTTP/1.1", host: "localhost:8001"
2017/05/10 21:01:25 [error] 7390#0: *15288 [lua] reports.lua:49: log(): [reports] could not set peer name for UDP socket: [toip() name lookup failed]: failed to receive reply from UDP server 10.135.1.21:53: timeout, context: ngx.timer

2) After that, I find my DNS server (IP address:10.135.1.21) is not working, I restart that server and start the DNS service. The DNS server is working now, and I use the command to ensure Kong server can use that DNS server:

command: nc -uvz 10.135.1.21 53
return data: Connection to 10.135.1.21 53 port [udp/domain] succeeded!
command: nslookup m.picclife.cn
return data:
Server:         10.135.1.21
Address:        10.135.1.21#53

Name:   m.picclife.cn
Address: 10.110.26.1

3) add the plugin by curl and get the response data:

curl -X POST http://localhost:8001/apis/test2/plugins --data "name=key-auth"

{"api_id":"58378633-1f68-2389-6290-c260dc23baec","id":"357d37ed-c03b-49f7-2653-89beafb52821","created_at":1494152015000,"enabled":true,"name":"key-auth","config":{"hide_credentials":false,"key_names":["apikey"],"anonymous":""}}

The return time has been reduced from 40 seconds to 10 seconds, the speed is much more faster than before, but I think it's slow, the speed should be faster and response time should be controlled within one second like before.

4) Check the error logs again and find that: [error] 12024#0: *47249 [lua] reports.lua:49: log(): [reports] could not set peer name for UDP socket: [toip() name lookup failed]: dns server error; 2 server failure, client: 127.0.0.1, server: kong_admin, request: "POST /apis/test3/plugins HTTP/1.1", host: "localhost:8001" I can connect to DNS server from Kong server and the DNS service is working, how to solve that problem? Thank you very much.

p0pr0ck5 commented 7 years ago

Sounds like a DNS resolver issue. @Tieske didn't you recently mention something about a 10 sec timeout bug due to potential record type confusion?

subnetmarco commented 7 years ago

@Tieske updates ^ ?

p0pr0ck5 commented 7 years ago

@ssholder do you see this with an upgrade to 0.10.3?

ssholder commented 7 years ago

@p0pr0ck5 When I found this issue: https://github.com/Mashape/kong/issues/2596 . I disable reporting by setting anonymous_reports off in the Kong config file, problem has been solved for the version of 0.10.x (include 0.10.3) , thank you very much!

p0pr0ck5 commented 7 years ago

Wonderful, thank you!