wandenberg / nginx-push-stream-module

A pure stream http push technology for your Nginx setup. Comet made easy and really scalable.
Other
2.22k stars 295 forks source link

Memory leak - getting HTTP 500 #138

Closed ghost closed 10 years ago

ghost commented 10 years ago

Hi,

We use the push stream module in the WS configuration to send messages to clients. It appears that the Nginx process size keeps increasing indefinitely and after a while we start getting HTTP 500 from the server. The log says: ngx_slab_alloc() failed: no memory. Some of our messages are 15-20KB in size.

I understand that this is actually an Nginx issue, not a push stream issue per se. I've found this discussion: https://github.com/wandenberg/nginx-push-stream-module/issues/87 and the patch you posted there: https://gist.github.com/wandenberg/6096183

Has this patch been pulled into the main Nginx trunk? Because it doesn't seem like the issue has been resolved.

Could you please point us in the right direction as to how to handle this situation? Right now it seems that the only way to resolve this is to regularly restart Nginx. Is there another way to handle this?

Many thanks

wandenberg commented 10 years ago

Hi @vedrankr The patch still under analysis like you can see here http://forum.nginx.org/read.php?29,240420,246715#msg-246715

You can apply the patch to your nginx code to solve the problem and do not need to restart the server.

ghost commented 10 years ago

Hi Wandenberg, Thank you for the info. I'll recompile with the patch and keep you updated.

ghost commented 10 years ago

Well, we've applied the patch but the memory footprint still seems to be increasing. It starts at about 3MB and keeps growing in 20KB increments. How often is this garbage collection supposed to kick in? Maybe we haven't waited long enough (only a couple of hours)?

EDIT: there have been no improvements except for the fact that the memory grows at a slower rate. Is it true that the message size limit is 3.5K?

wandenberg commented 10 years ago

It only defrag the memory when needed. So, only when the memory is full, it will check if there are empty continuous areas and merge them.

The memory will grow in size but you will not see the no memory message on logs. Unless you set a shared memory size incompatible with your application. On Apr 21, 2014 5:22 AM, "Vedran" notifications@github.com wrote:

Well, we've applied the patch but the memory footprint still seems to be increasing. It starts at about 3MB and keeps growing in size. How often is this garbage collection supposed to kick in? Maybe we haven't waited long enough (only a couple of hours)?

— Reply to this email directly or view it on GitHubhttps://github.com/wandenberg/nginx-push-stream-module/issues/138#issuecomment-40932025 .

ghost commented 10 years ago

You're right, the fix seems to be working. Our push_stream_shared_memory_size is 100M and the app stabilized around that figure. I really appreciate the hard work you put into this. The push stream module is a fantastic piece of software (it just might be a good idea to maybe make this issue known somewhere, or include a link to the patch on the project page).

Thanks

tszming commented 10 years ago

Fixed in nginx: http://hg.nginx.org/nginx/rev/c46657e391a3

qianxinyu commented 8 years ago

I ran into this problem too and I already use the 1.8 the latest Nginx in which version I think the bug has been fixed. Have I missed something? Are there any config items to set the memory usage of Nginx ?