apisix icon indicating copy to clipboard operation
apisix copied to clipboard

bug: memory leak

Open Hxhong opened this issue 3 years ago • 0 comments

Current Behavior

I request one proxy url once a minute on the premise that all plugins are closed, I found that the memory is higher than last request, and the memory isn't released even for a few hours.

This is the memory monitor result when I use prometheus and grafana to monitor Linux machine. 1660124821222

Expected Behavior

How long will the memory be released? Can we set memory released time or disable caching request?

Error Logs

No response

Steps to Reproduce

  1. Run APISIX via the Docker image.
  2. Create a Route with the Admin API.

Environment

  • APISIX version (run apisix version): 2.10.4 or 2.15.0, docker centos images
  • Operating system (run uname -a): CentOS Linux release 7.8.2003 (Core)
  • OpenResty / Nginx version (run openresty -V or nginx -V): openresty/1.21.4.1
  • etcd version, if relevant (run curl http://127.0.0.1:9090/v1/server_info): 3.5.4
  • APISIX Dashboard version, if relevant:
  • Plugin runner version, for issues related to plugin runners:
  • LuaRocks version, for installation issues (run luarocks --version):

Hxhong avatar Aug 10 '22 09:08 Hxhong

What kind of requests are you sending? Please give more details, thanks!

tokers avatar Aug 11 '22 01:08 tokers

What kind of requests are you sending? Please give more details, thanks!

This is the route I set: curl http://127.0.0.1:9080/apisix/admin/routes/1234554321 -H 'X-API-KEY: 123qwe' -X PUT -d ' { "methods": ["GET","POST","PUT","DELETE","OPTIONS"], "uris": ["/myapp", "/myapp/**"], "upstream": { "type": "roundrobin", "nodes": { "x.x.x.x:80": 1 } } }'

The upstream is a front-end application of nginx agent. When I try other applications, there is also a memory leak problem. By the way, compared with the results after yesterday's test, the memory has not been released now.

Hxhong avatar Aug 11 '22 01:08 Hxhong

We can use the flamgraph to find memory leaks.

see: openresty/stapxx#sample-bt-leaks

Or you can also use X-Ray to diagnose the memory issue: openresty.com.cn/cn/xray. Note that I am not the developer of X-Ray (it is a commercial product developed by others).

tzssangglass avatar Aug 11 '22 02:08 tzssangglass

We can use the flamgraph to find memory leaks.

see: openresty/stapxx#sample-bt-leaks

Or you can also use X-Ray to diagnose the memory issue: openresty.com.cn/cn/xray. Note that I am not the developer of X-Ray (it is a commercial product developed by others).

It's hard for me to use sample-bt-leaks, and X-Ray is not free...Can you check it first or teach me how to use sample-bt-leaks?

Hxhong avatar Aug 11 '22 06:08 Hxhong

It's hard for me to use sample-bt-leaks

We have the script to generate the flamgraph: https://github.com/apache/apisix/blob/master/ci/performance_test.sh modify this script to use sample-bt-leaks, lj-lua-stacks.sxx --> sample-bt-leaks.

and X-Ray is not free...

X-Ray can try before you buy.

Can you check it first or teach me how to use sample-bt-leaks?

I can do it, but I don't have the memory leak environment like you.

tzssangglass avatar Aug 12 '22 02:08 tzssangglass