-
Notifications
You must be signed in to change notification settings - Fork 2k
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
100% cpu #278
Comments
Thank you for the report! Assuming you're on Linux, could you please generate a C-land flamegraph for the nginx worker process spinning at 100% CPU usage? See https://github.com/agentzh/nginx-systemtap-toolkit#ngx-sample-bt Also, please use the gdb command "bt full" instead of "bt" to get the backtrace when you're in gdb, so that we can have more context information :) Thanks! |
BTW, is there anything interesting in your nginx's error log file? If the file is empty, please check if you configure the error log filtering level too high in the "error_log" directive in your nginx.conf. Thanks! |
hi,agentzh! Here is the svg file, and the bt full info is: #0 0x00002aee1279a1a6 in ?? () from /usr/lib/libluajit-5.1.so.2 |
emm, I saw "nginx: lua atpanic: Lua VM crashed, reason: not enough memory" in my error_log file. BTW, when the nginx worker process spinning at 100% CPU usage, it's memory usage is 1gb. |
@cs0604 Okay, you're having memory leaks in your Lua VM and your Lua GC eventually hits the 1GB limit on Linux. Because there've been quite a few important memory leak bugfixes since the ngx_lua 0.8.3 release, could you please try upgrading your ngx_lua to the latest 0.8.8 version? (or you can just upgrade to ngx_openresty 1.4.2.5 if you're using the bundle). If the problem persists, you should check if your own Lua code leaks memory. |
I upgrade the ngx_lua to the latest 0.8.8 version, but the problem still exists. How can I find what takes up memory in Lua VM ? |
Hello! On Fri, Sep 13, 2013 at 10:47 PM, cs0604 wrote:
You can try using the luatraverse.lua script to inspect your Lua memory usage:
To me it looks like some programming mistakes in your Lua code :) For the reference, you can take a look at the lua-resty-upload module
Basically you should avoid reading all the incoming big data into the Regards, |
@cs0604 Any updates on this issue? |
@agentzh It seems ok when I add "collectgarbage('collect')" at the end of the code , and the problem doesn't recur. Thank you for your suggestions, but it's hard to deal with request body in streaming mode ,because the body is encoded by protobuf, and the real content in the protobuf is encoded by aes algorithm ... |
@cs0604 Forcing a full GC cycle is expensive but it seems that you're just allocating too much in the LuaJIT GC. If you really want to handle big request bodies, you should make your data format itself streaming. Anyway, you can work around the 1GB limit by spawning more Nginx workers and/or use the following library to increase the limit to 4GB on x86_64: https://github.com/Neopallium/mmap_lowmem -agentzh |
Anyway, I'm closing this. The upcoming LuaJIT 3.0's new GC will probably make your existing Lua code doing full buffered processing behave better in the future. Still, I believe you should optimize your data format and processing algorithm. |
Hello, I found a strange problem that the cpu usage is too high in several workers. Here is the gdb info:
#0 0x00002b6a94401183 in ?? () from /usr/lib/libluajit-5.1.so.2
#1 0x00002b6a94401415 in lua_getstack () from /usr/lib/libluajit-5.1.so.2
#2 0x000000000053fb19 in ngx_http_lua_thread_traceback (L=0x40f22378, co=0x7ef24628, coctx=0xbcdbfd0)
#3 0x000000000053d176 in ngx_http_lua_run_thread (L=0x40f22378, r=0xbcdaf60, ctx=0xbcdbfb8, nrets=1)
#4 0x0000000000526dc9 in ngx_http_lua_subrequest_resume (r=0xbcdaf60)
#5 0x0000000000541f5e in ngx_http_lua_content_wev_handler (r=0xbcdaf60)
#6 0x0000000000499caa in ngx_http_run_posted_requests (c=0x2b6a94d32250) at src/http/ngx_http_request.c:2170
#7 0x00000000004b1fa3 in ngx_http_upstream_handler (ev=0x2b6a956931b0) at src/http/ngx_http_upstream.c:972
#8 0x000000000046f860 in ngx_event_process_posted (cycle=0xbbdfdd0, posted=0x9b3088) at src/event/ngx_event_posted.c:40
#9 0x000000000046d3a9 in ngx_process_events_and_timers (cycle=0xbbdfdd0) at src/event/ngx_event.c:276
#10 0x000000000047a59c in ngx_worker_process_cycle (cycle=0xbbdfdd0, data=0x7) at src/os/unix/ngx_process_cycle.c:807
#11 0x0000000000477185 in ngx_spawn_process (cycle=0xbbdfdd0, proc=0x47a3e9 <ngx_worker_process_cycle>, data=0x7, name=0x6d11be "worker process", respawn=-4)
#12 0x0000000000479477 in ngx_start_worker_processes (cycle=0xbbdfdd0, n=8, type=-4) at src/os/unix/ngx_process_cycle.c:362
#13 0x0000000000479075 in ngx_master_process_cycle (cycle=0xbbdfdd0) at src/os/unix/ngx_process_cycle.c:249
#14 0x0000000000448a19 in main (argc=3, argv=0x7fffaa3edea8) at src/core/nginx.c:412
I can't find any clue to solve the problem,please help me ...
I use the nginx_lua v0.8.3 , and I can't reproduce the problem ,but when the nginx serve many clients for several hours , it comes again.
The text was updated successfully, but these errors were encountered: