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

Seems like memory leak when using with websockets #87

Closed IPv6 closed 11 years ago

IPv6 commented 11 years ago

I am using push module 0.3.5 to send messages to clients. after several hours of such "messaging" push module stops to work and nginx is filled with error push stream module: unable to allocate message in shared memory there is no ngx_slab_alloc() failed errors in log, at the same time

nginx config is: push_stream_shared_memory_size 128M; push_stream_max_messages_stored_per_channel 20; push_stream_shared_memory_cleanup_objects_ttl 10s; push_stream_channel_inactivity_time 120s; push_stream_message_ttl 120s;

location pub push_stream_publisher; push_stream_keepalive on; push_stream_store_messages on;

location sub more_set_headers 'Content-Type: text/plain; charset=UTF-8'; push_stream_websocket; push_stream_subscriber_connection_ttl 360s; push_stream_ping_message_interval 10s;

set $push_stream_channels_path $arg_rtslots;

messages are 10-20 Kb in size (in common)

Push module stats are: u'pushmod': { u'broadcast_channels': u'0', u'by_worker': [ { u'pid': u'9691', u'subscribers': u'0', u'uptime': u'22107'}, { u'pid': u'9692', u'subscribers': u'1', u'uptime': u'22107'}, { u'pid': u'9693', u'subscribers': u'2', u'uptime': u'22107'}, { u'pid': u'9694', u'subscribers': u'0', u'uptime': u'22107'}, { u'pid': u'9695', u'subscribers': u'2', u'uptime': u'22107'}, { u'pid': u'9696', u'subscribers': u'1', u'uptime': u'22107'}, { u'pid': u'9697', u'subscribers': u'0', u'uptime': u'22107'}], u'channels': u'12', u'channels_in_trash': u'0', u'hostname': u'debian-60-squeeze-64-minimal', u'messages_in_trash': u'3', u'published_messages': u'41140', u'stored_messages': u'51', u'subscribers': u'6', u'time': u'2013-07-04T12:43:31', u'uptime': u'22107'}


may be there is something wrong with settings? any advice is welcome

wandenberg commented 11 years ago

Hi, again this problem is not related with websocket :) Nginx does not work very well when we allocate more memory than a page size on shared memory. I was talking about that with Maxim and a hope have a patch to solve this problem asap. You can check the thread about that here http://forum.nginx.org/read.php?29,240420,240420#msg-240420

IPv6 commented 11 years ago

i see, thanks!!!

So currenty there is only one option - keep message size under 3Kb (+1Kb for push module stuff), am i right?

IPv6 commented 11 years ago

btw, i can test patch too, if you share it :)

wandenberg commented 11 years ago

Yes, for now, keep your message + message template under 3.5Kb. As soon as I have a patch I post here again. ;)

wandenberg commented 11 years ago

Hi,

here is the patch I sent to nginx-devel list. If you can, help me to test it. https://gist.github.com/wandenberg/6096183