Closed Jorgevillada closed 3 years ago
Yes, I can reproduce this with latest next
using:
for i in $(seq 1 1000)
do
curl -k -s -o /dev/null --http1.1 -X POST 'https://localhost:8444/config' --form 'config=@kong_prod.yaml'
ps -Ao pid,rss,comm,args | grep nginx
done
And I started my local Kong with:
KONG_NGINX_MAIN_WORKER_RLIMIT_NOFILE=4096 \
KONG_NGINX_EVENTS_WORKER_CONNECTIONS=4096 \
KONG_WORKER_STATE_UPDATE_FREQUENCY=3600 \
KONG_WORKER_CONSISTENCY=eventual \
KONG_ADMIN_LISTEN="127.0.0.1:8444 http2 ssl" \
KONG_PROXY_LISTEN="0.0.0.0:8000, 0.0.0.0:8443 http2 ssl" \
KONG_STATUS_LISTEN="0.0.0.0:8100" \
KONG_CLUSTER_LISTEN=off \
KONG_STREAM_LISTEN=off \
KONG_DATABASE=off \
KONG_NGINX_MAIN_WORKER_PROCESSES=1 \
KONG_TRUSTED_IPS="0.0.0.0/0,::/0" \
KONG_PLUGINS=bundled \
./bin/kong start
Initial investigation shows that pending timers grow. This is probably a leak in timers for DNS client and/or healthchecks.
The timer leak is gone if I remove upstreams
and targets
from yaml
, but memory leak seems still be present even then.
I have found the place where this occurs, and this is the line: https://github.com/Kong/kong/blob/next/kong/db/schema/init.lua#L886
The starting point of the leak is this: https://github.com/Kong/kong/blob/next/kong/db/schema/others/declarative_config.lua#L628
Summary
I am currently using kong in db-less mode with kong-ingress-controller. there is a limit of 1.5GB of ram (not sure if it is enough) for each kong proxy. there are 3 in total (I have also tried with a single replica and with 2, with the same result).
I think it is related to https://github.com/Kong/kong/issues/6055, this change is not found in master. https://github.com/Kong/kong/commit/0eb15e65e0290967341108e3052e69462f1f0b81
it always starts with 180-200mb and with every update from ingress-controller it increases constantly.
I have configured these parameters in kong-proxy.
in ingress-controller I don't know if they work, but the behavior has improved.
now it takes 24 hours to reach the memory limit(before it took 12 hours)
Steps To Reproduce
1.run kong in db-less mode
result with empty config
Thu 05 Nov 2020 02:37:41 PM -05 PID RSS COMMAND COMMAND 1 30m nginx nginx: master process /usr/local/openresty/nginx/sbin/nginx -p /usr/local/kong -c nginx.conf 21 86m nginx nginx: worker process 22 4 ps ps -o pid,rss,comm,args
1 hour after
I only make this request, I do not make any request to port 8000. request to status
response: kong_status.json
Additional Details & Logs