isage / lua-resty-moongoo

MongoDB library for OpenResty
Do What The F*ck You Want To Public License
118 stars 33 forks source link

Memory leak? #7

Closed travisbell closed 7 years ago

travisbell commented 7 years ago

Hey man,

I noticed that when I went live with the moongoo code my memory usage started climbing, and climbing and climbing.

So I went ahead and created a small, absolutely bare bones project with only the code in your README, I started pounding it with wrk and sure enough, the same thing happens.

Are you able to take a look at this? I don't have any clue how to start debugging this nor the skills to even do anything about it.

travisbell commented 7 years ago

Oh ya, might help to have some useful info:

root@ubuntu:~# /usr/local/openresty/nginx/sbin/nginx -V
nginx version: openresty/1.11.2.3
built by gcc 4.8.4 (Ubuntu 4.8.4-2ubuntu1~14.04.3)
built with OpenSSL 1.0.1f 6 Jan 2014
TLS SNI support enabled
configure arguments: --prefix=/usr/local/openresty/nginx --with-cc-opt=-O2 --add-module=../ngx_devel_kit-0.3.0 --add-module=../echo-nginx-module-0.60 --add-module=../xss-nginx-module-0.05 --add-module=../ngx_coolkit-0.2rc3 --add-module=../set-misc-nginx-module-0.31 --add-module=../form-input-nginx-module-0.12 --add-module=../encrypted-session-nginx-module-0.06 --add-module=../srcache-nginx-module-0.31 --add-module=../ngx_lua-0.10.8 --add-module=../ngx_lua_upstream-0.06 --add-module=../headers-more-nginx-module-0.32 --add-module=../array-var-nginx-module-0.05 --add-module=../memc-nginx-module-0.18 --add-module=../redis2-nginx-module-0.14 --add-module=../redis-nginx-module-0.3.7 --add-module=../rds-json-nginx-module-0.14 --add-module=../rds-csv-nginx-module-0.07 --with-ld-opt=-Wl,-rpath,/usr/local/openresty/luajit/lib --with-http_ssl_module

That's a completely standard OR install, no special flags or modules. Just stock ./configure.

The moongoo method I was testing in my route was a find_one call. I just hit it with a:

wrk -d 10m -c 50 -t 8 --latency "http://x.x.x.x"

And my Nginx worker ends up using a ton of memory. It continues to grow and grow and never stops growing.

isage commented 7 years ago

I'll look into it, but it'll take some time. Meanwhile, can you try with latest lua-cbson?

travisbell commented 7 years ago

Promising results in my test dev. Looks like GC is properly cleaning up memory now, and I am not seeing it grow unbounded. Given only my test of course.

I'll push this production and see what it looks like there.

travisbell commented 7 years ago

Here's what the last 12 hours look like compared to the weekend:

dashboard_system

Pretty noticeable difference. I'd say we're looking pretty good. 👍