-
Notifications
You must be signed in to change notification settings - Fork 3
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
memory leak when more request is received #4
Comments
request to nginx with QPS > 4000, it will happend definitely, you may test it. |
这个插件只有一个已知的内存泄漏, 只发生在后端serverlist频繁刷新的时候, 但按说这种时候其泄漏量也很小基本上是稳定的. 其余时候在我们公司的线上是稳定的, 包括双十一期间, 我们的请求量在单机8000以上. 你能把你的serverlist内容贴一下么? |
serverlist返回的就是很多行如下配置信息: server server001:8000 weight=10 max_fails=5 fail_timeout=1s; 大概30个左右,内存泄露很明显。 |
能把整个文件附在附件里吗? |
curl http://192.168.0.10:8080/upstream/apiServerList 其他见文件 |
OK, I saw, and the case is caused by the pool used by the serverlist parser, which is the main conf's never-destroyed pool. Every parse action may allocate some memory, and never free. It is intentionally, because nginx is designed only support static conf, and the upstream servers struct in the static conf are used in many code corners, so free outdated upstream servers struct is very hard, except you can accept coredump ---- which is occurred in many other dynamic upstream modules, like this: GUI/nginx-upstream-dynamic-servers#30. and the pull request in this issue was incomplete either, it will coredump in keep-alive enabled connections. As a workaround, you can use LAST-MODIFIED or ETAG http header and 304 http status code to tell the module the serverlist are not refreshed, and the module then will bypass parse serverlist, and bypass memory allocation eventually. |
你中间做了什么变更么? serverlists有极频繁变化和大量增加? 能不能确认返回值是304? 只要是304, 就一定不会分配新内存. |
你好,我想我已经解决了这个动态解析模块的memory crash 和 memory leak的问题,你可以尝试一下我的模块或者帮我检查一下吗? 谢谢 |
在原来的模块我也提了一个pr,专门解决了内存问题,你也可以看一下 |
@zhaofeng0019 This looks pretty cool. There are a couple of things going on here: using a pool queue, avoiding exiting the process (and initializing that queue on starting a new process) and using ngx_http_upstream_init_round_robin vs init (as well as requiring a mod to the main source. Do all these things need to be done together or each of the them alone solves different issues? The reason I ask is that i use another 3rd party lib (https://github.com/gnosek/nginx-upstream-fair) and I'm running into issues (not really memory growing fast since I use the LAST-MODIFIED/ETAG) where after a while, nginx just starts trying to make connections against the dummy server: |
cinquemb, thank you for looking into my code. mod to the main source is not necessary. And about the 3rd party lib (https://github.com/gnosek/nginx-upstream-fair) thanks again. |
yeah i saw that pr @zhaofeng0019, the thing is that https://github.com/abadcafe/nginx-upstream-serverlist works differently than https://github.com/GUI/nginx-upstream-dynamic-servers so its not a 1 to 1 map with this project. but I can test out a couple of the changes you made ( https://github.com/GUI/nginx-upstream-dynamic-servers/pull/33/commits) by porting them to this module and see if they clear up some things im seeing. thanks! |
I found there is a meory leack issue when I used this on our production env.
We used nginx server with 4core , 4GB memory
When I used nginx without this moudle, on our production env, nginx used 20% memory.
When I just add serverlist_service at http , and no call on it , nginx used 50% memory.
When call serverlist_service in upstream, nginx memory will increasing up to almost 100%,
I had a screen shot for server:
nginx -V output with nginx-upstream-serverlist module:
The text was updated successfully, but these errors were encountered: