ejabberd - Comments for "MUC: Ability to disable presence broadcast to users with &amp;#039;Visitor&amp;#039; Affiliation" https://www.ejabberd.im/node/5055 en HI Badlop this patch solves https://www.ejabberd.im/node/5055#comment-58310 <p>HI Badlop this patch solves the problem but i have some thoughts about how presence is handled in mod_muc module. </p> <p>On a high level this is my understanding, For each user who joins the chat room, we are storing the presence of all the other users who are also present in the room. So as the number of clients increase the presence data associated with each client also increases exponentially. This eventually leads to the out of memory exceptions on the host. </p> <p>Although storing the presence data for each user makes sense as we can support features like fine grained presence notifications for each user but at this point there is no way for the user to configure these in a MUC room. </p> <p>If we can change the MUC module to store all the presence information at one place then i think we can avoid the excessive use of memory for a room which intends to server thousands of clients, on the flip side we will not be able to provide a fine grained presence settings for each user. </p> <p>Can somebody confirm if my understanding of the presence problem is correct ? Also if someone can give me pointers on how the presence broadcast works and how we can tailor this module to suit the needs of large Chatrooms. it will be very helpful.</p> Tue, 31 Jan 2012 22:41:51 +0000 sundeep comment 58310 at https://www.ejabberd.im With version 2.1.10, eajbberd https://www.ejabberd.im/node/5055#comment-58309 <p>With version 2.1.10, eajbberd opens up a file for each connection made to the server. So ejabberd was crashing as soon as i reach 1000 users. I increased the number of open files to a higher number and then ejabberd stops crashing. </p> <p>Is it a bug with version 2.1.10 ? Also can someone shed some light on what this open filed does ?</p> Tue, 31 Jan 2012 06:25:35 +0000 sundeep comment 58309 at https://www.ejabberd.im Hi badlop, I tested these https://www.ejabberd.im/node/5055#comment-58308 <p>Hi badlop,</p> <p>I tested these changes and the memory usage of ejabberd is very low (~ 160 mb ) for 1000 clients. This is very promising but ejabberd is crashing after some time. ejabberd crashes with the following error</p> <p>=SUPERVISOR REPORT==== 30-Jan-2012::11:18:48 ===<br /> Supervisor: {local,ejabberd_sup}<br /> Context: shutdown_error<br /> Reason: {{function_clause,<br /> [{gen,call,<br /> [{rex,<br /> {error,{node_not_running,ejabberd@localhost}}},<br /> '$gen_call',<br /> {call,mnesia,remote_dirty_select,<br /> [session,<br /> [{{session,{'_','$1'},'_','_','_','_'},<br /> [{'==',{node,'$1'},ejabberd@localhost}],<br /> ['$_']}]],<br /> &lt;0.39.0&gt;},<br /> infinity],<br /> [{file,"gen.erl"},{line,146}]},<br /> {gen_server,call,3,<br /> [{file,"gen_server.erl"},{line,184}]},<br /> {rpc,do_call,3,[{file,"rpc.erl"},{line,333}]},<br /> {mnesia,do_dirty_rpc,5,<br /> [{file,"mnesia.erl"},{line,1807}]},<br /> {ejabberd_sm,'-recount_session_table/1-fun-2-',1,<br /> [{file,"ejabberd_sm.erl"},{line,385}]},<br /> {mnesia_tm,non_transaction,5,<br /> [{file,"mnesia_tm.erl"},{line,734}]},<br /> {ejabberd_sm,handle_info,2,<br /> [{file,"ejabberd_sm.erl"},{line,324}]},<br /> {gen_server,handle_msg,5,<br /> [{file,"gen_server.erl"},{line,597}]}]},<br /> {gen_server,call,<br /> [{rex,{error,{node_not_running,ejabberd@localhost}}},<br /> {call,mnesia,remote_dirty_select,<br /> [session,<br /> [{{session,{'_','$1'},'_','_','_','_'},<br /> [{'==',{node,'$1'},ejabberd@localhost}],<br /> ['$_']}]],<br /> &lt;0.39.0&gt;},<br /> infinity]}}<br /> Offender: [{pid,&lt;0.251.0&gt;},<br /> {name,ejabberd_sm},<br /> {mfargs,{ejabberd_sm,start_link,[]}},<br /> {restart_type,permanent},<br /> {shutdown,brutal_kill},<br /> {child_type,worker}]</p> <p>{"Kernel pid terminated",application_controller,"{application_terminated,mnesia,shutdown}"}</p> <p>Crash dump was written to: //var/log/ejabberd/erl_crash_20120130-110341.dump<br /> Kernel pid terminated (application_controller) ({application_terminated,mnesia,shutdown})</p> <p>I have the entire crash log and if you want i can give you a link to download the crash log. I am trying to tweak the Mnesia tables setting and will let you know if that helps. In the mean time if you can provide some guidance on this, it will be much appreciated. </p> <p>Thanks again for the patch.</p> Mon, 30 Jan 2012 11:33:41 +0000 sundeep comment 58308 at https://www.ejabberd.im Hi badlop, Thanks for the https://www.ejabberd.im/node/5055#comment-58302 <p>Hi badlop,</p> <p>Thanks for the patch and i am trying it out now. I wanted to know if joining &gt;500 users into a single muc room is possible? was it desinged to handle such high numbers ? I am also curious about why ejabberd takes so much memory for higher numbers? Do we need to tweak any parameters on the ejabberd-muc configuration to acheive such numbers ? i have already played with all the params mentioned in ejabberd operation manual but dont see any improvements. </p> <p>Any advice on this is highly appreciated.</p> <p>Thanks</p> Sun, 29 Jan 2012 19:49:14 +0000 sundeep comment 58302 at https://www.ejabberd.im Here is a simple patch that https://www.ejabberd.im/node/5055#comment-58043 <p>Here is a simple patch that disables presene broadcast. This means that all rooms are "dark": noone can see anybody else.</p> <pre> diff --git a/src/mod_muc/mod_muc_room.erl b/src/mod_muc/mod_muc_room.erl index 164805d..5513064 100644 --- a/src/mod_muc/mod_muc_room.erl +++ b/src/mod_muc/mod_muc_room.erl @@ -2096,6 +2096,8 @@ send_new_presence(NJID, Reason, StateData) -&gt; Affiliation = get_affiliation(LJID, StateData), SAffiliation = affiliation_to_list(Affiliation), SRole = role_to_list(Role), + Destinations = [{LJID, Info} || {LJID, Info} &lt;- + ?DICT:to_list(StateData#state.users), (NJID == Info#user.jid)], lists:foreach( fun({_LJID, Info}) -&gt; ItemAttrs = @@ -2145,7 +2147,7 @@ send_new_presence(NJID, Reason, StateData) -&gt; jlib:jid_replace_resource(StateData#state.jid, Nick), Info#user.jid, Packet) - end, ?DICT:to_list(StateData#state.users)). + end, Destinations). send_existing_presences(ToJID, StateData) -&gt; @@ -2189,7 +2191,7 @@ send_existing_presences(ToJID, StateData) -&gt; RealToJID, Packet) end - end, ?DICT:to_list(StateData#state.nicks)). + end, []). now_to_usec({MSec, Sec, USec}) -&gt; </pre> Tue, 15 Nov 2011 15:25:05 +0000 mfoss comment 58043 at https://www.ejabberd.im