load test

HI.
I do load test on ejabberd 16.01.
config chat server: ejabberd server 16.01 , os debian 8.2 , 8 G Ram, CPU 4 core

when the number users reach to 30k, it returns this error and working. how to fix it?
tsung config : send message with size 4 k and arrivalrate="1000" unit="second"

>>,<<"mydomain.com">>,<<"tsung">>,<<"user003117">>,<<"mydomain.com">>,<<"tsung">>},{jid,<<"user004308">>,<<"mydomain.com">>,<<>>,<<"user004308">>,<<"mydomain.com">>,<<>>}]}
2016-01-24 08:31:31.834 [error] <0.5371.0>@ejabberd_hooks:run_fold1:368 {timeout,{gen_server,call,[cache_tab_archive_prefs_2,{lookup,{<<"user002132">>,<<"mydomain.com">>},#Fun<mod_mam.9.13561693>},60000]}}
running hook: {user_send_packet,[{state,{socket_state,gen_tcp,#Port<0.18379>,<0.5370.0>},ejabberd_socket,#Ref<0.0.0.30685>,false,<<"6754996563123156433">>,undefined,c2s,c2s_shaper,false,true,false,false,[verify_none,compression_none,{protocol_options,<<"no_sslv3">>},{certfile,<<"/opt/ejabberd-16.01/conf/server.pem">>}],true,{jid,<<"user002132">>,<<"mydomain.com">>,<<"tsung">>,<<"user002132">>,<<"mydomain.com">>,<<"tsung">>},<<"user002132">>,<<"mydomain.com">>,<<"tsung">>,{{1453,611599,505577},<0.5371.0>},{1,{{<<"user002132">>,<<"mydomain.com">>,<<>>},nil,nil}},{1,{{<<"user002132">>,<<"mydomain.com">>,<<>>},nil,nil}},{1,{{<<"user002132">>,<<"mydomain.com">>,<<>>},nil,nil}},{xmlel,<<"presence">>,[{<<"id">>,<<"14049">>}],[]},{1453,611603,483407},{userlist,none,[],false},c2s,ejabberd_auth_odbc,{{192,168,120,32},27129},[{caps_resources,{0,nil}}],active,[],inactive,undefined,undefined,1000,undefined,300,300,false,0,0,<<>>},{jid,<<"user002132">>,<<"mydomain.com">>,<<"tsung">>,<<"user002132">>,<<"mydomain.com">>,<<"tsung">>},{jid,<<"user008810">>,<<"mydomain.com">>,<<>>,<<"user008810">>,<<"mydomain.com">>,<<>>}]}
2016-01-24 08:31:31.835 [error] <0.5464.0>@ejabberd_hooks:run_fold1:368 {timeout,{gen_server,call,[cache_tab_archive_prefs_1,{lookup,{<<"user003183">>,<<"mydomain.com">>},#Fun<mod_mam.9.13561693>},60000]}}
running hook: {user_send_packet,[{state,{socket_state,gen_tcp,#Port<0.18425>,<0.5463.0>},ejabberd_socket,#Ref<0.0.0.31712>,false,<<"16575348447772041551">>,undefined,c2s,c2s_shaper,false,true,false,false,[verify_none,compression_none,{protocol_options,<<"no_sslv3">>},{certfile,<<"/opt/ejabberd-16.01/conf/server.pem">>}],true,{jid,<<"user003183">>,<<"mydomain.com">>,<<"tsung">>,<<"user003183">>,<<"mydomain.com">>,<<"tsung">>},<<"user003183">>,<<"mydomain.com">>,<<"tsung">>,{{1453,611599,593370},<0.5464.0>},{1,{{<<"user003183">>,<<"mydomain.com">>,<<>>},nil,nil}},{1,{{<<"user003183">>,<<"mydomain.com">>,<<>>},nil,nil}},{1,{{<<"user003183">>,<<"mydomain.com">>,<<>>},nil,nil}},{xmlel,<<"presence">>,[{<<"id">>,<<"14050">>}],[]},{1453,611603,216832},{userlist,none,[],false},c2s,ejabberd_auth_odbc,{{192,168,120,36},16070},[{caps_resources,{0,nil}}],active,[],inactive,undefined,undefined,1000,undefined,300,300,false,0,0,<<>>},{jid,<<"user003183">>,<<"mydomain.com">>,<<"tsung">>,<<"user003183">>,<<"mydomain.com">>,<<"tsung">>},{jid,<<"user0011450">>,<<"mydomain.com">>,<<>>,<<"user0011450">>,<<"mydomain.com">>,<<>>}]}
2016-01-24 08:31:31.836 [info] <0.28475.2>@ejabberd_c2s:wait_for_feature_request:740 ({socket_state,gen_tcp,#Port<0.62537>,<0.28474.2>}) Accepted authentication for user0099387 by ejabberd_auth_odbc from 192.168.120.31
2016-01-24 08:31:31.836 [info] <0.29202.2>@ejabberd_c2s:wait_for_feature_request:767 ({socket_state,gen_tcp,#Port<0.62897>,<0.29201.2>}) Failed authentication for user00100217@mydomain.com from 192.168.120.35
2016-01-24 08:31:31.837 [info] <0.26749.2>@ejabberd_c2s:wait_for_session:1106 ({socket_state,gen_tcp,#Port<0.61680>,<0.26748.2>}) Opened session for user0097302@mydomain.com/tsung
2016-01-24 08:31:31.838 [info] <0.28491.2>@ejabberd_c2s:wait_for_feature_request:740 ({socket_state,gen_tcp,#Port<0.62545>,<0.28490.2>}) Accepted authentication for user0094252 by ejabberd_auth_odbc from 192.168.120.36
2016-01-24 08:31:31.838 [info] <0.29396.2>@ejabberd_c2s:wait_for_feature_request:740 ({socket_state,gen_tcp,#Port<0.62994>,<0.29395.2>}) Accepted authentication for user0099946 by ejabberd_auth_odbc from 192.168.120.39
2016-01-24 08:31:31.838 [info] <0.29092.2>@ejabberd_c2s:wait_for_feature_request:740 ({socket_state,gen_tcp,#Port<0.62842>,<0.29091.2>}) Accepted authentication for user0026190 by ejabberd_auth_odbc from 192.168.120.38
2016-01-24 08:31:31.839 [info] <0.28785.2>@ejabberd_c2s:wait_for_feature_request:740 ({socket_state,gen_tcp,#Port<0.62692>,<0.28784.2>}) Accepted authentication for user0099741 by ejabberd_auth_odbc from 192.168.120.38
2016-01-24 08:31:31.839 [error] <0.5275.0>@ejabberd_hooks:run_fold1:368 {timeout,{gen_server,call,[cache_tab_archive_prefs_1,{lookup,{<<"user003001">>,<<"mydomain.com">>},#Fun<mod_mam.9.13561693>},60000]}}
running hook: {user_send_packet,[{state,{socket_state,gen_tcp,#Port<0.18331>,<0.5274.0>},ejabberd_socket,#Ref<0.0.0.29652>,false,<<"10239203299053377594">>,undefined,c2s,c2s_shaper,false,true,false,false,[verify_none,compression_none,{protocol_options,<<"no_sslv3">>},{certfile,<<"/opt/ejabberd-16.01/conf/server.pem">>}],true,{jid,<<"user003001">>,<<"mydomain.com">>,<<"tsung">>,<<"user003001">>,<<"mydomain.com">>,<<"tsung">>},<<"user003001">>,<<"mydomain.com">>,<<"tsung">>,{{1453,611599,427398},<0.5275.0>},{1,{{<<"user003001">>,<<"mydomain.com">>,<<>>},nil,nil}},{1,{{<<"user003001">>,<<"mydomain.com">>,<<>>},nil,nil}},{1,{{<<"user003001">>,<<"mydomain.com">>,<<>>},nil,nil}},{xmlel,<<"presence">>,[{<<"id">>,<<"14075">>}],[]},{1453,611603,874966},{userlist,none,[],false},c2s,ejabberd_auth_odbc,{{192,168,120,32},50633},[{caps_resources,{0,nil}}],active,[],inactive,undefined,undefined,1000,undefined,300,300,false,0,0,<<>>},{jid,<<"user003001">>,<<"mydomain.com">>,<<"tsung">>,<<"user003001">>,<<"mydomain.com">>,<<"tsung">>},{jid,<<"user004727">>,<<"mydomain.com">>,<<>>,<<"user004727">>,<<"mydomain.com">>,<<>>}]}
2016-01-24 08:31:31.839 [error] <0.5323.0>@ejabberd_hooks:run_fold1:368 {timeout,{gen_server,call,[cache_tab_archive_prefs_3,{lookup,{<<"user003051">>,<<"mydomain.com">>},#Fun<mod_mam.9.13561693>},60000]}}
running hook: {user_send_packet,[{state,{socket_state,gen_tcp,#Port<0.18355>,<0.5322.0>},ejabberd_socket,#Ref<0.0.0.30243>,false,<<"2471182803424395863">>,undefined,c2s,c2s_shaper,false,true,false,false,[verify_none,compression_none,{protocol_options,<<"no_sslv3">>},{certfile,<<"/opt/ejabberd-16.01/conf/server.pem">>}],true,{jid,<<"user003051">>,<<"mydomain.com">>,<<"tsung">>,<<"user003051">>,<<"mydomain.com">>,<<"tsung">>},<<"user003051">>,<<"mydomain.com">>,<<"tsung">>,{{1453,611599,469042},<0.5323.0>},{1,{{<<"user003051">>,<<"mydomain.com">>,<<>>},nil,nil}},{1,{{<<"user003051">>,<<"mydomain.com">>,<<>>},nil,nil}},{1,{{<<"user003051">>,<<"mydomain.com">>,<<>>},nil,nil}},{xmlel,<<"presence">>,[{<<"id">>,<<"14076">>}],[]},{1453,611603,396944},{userlist,none,[],false},c2s,ejabberd_auth_odbc,{{192,168,120,36},15920},[{caps_resources,{0,nil}}],active,[],inactive,undefined,undefined,1000,undefined,300,300,false,0,0,<<>>},{jid,<<"user003051">>,<<"mydomain.com">>,<<"tsung">>,<<"user003051">>,<<"mydomain.com">>,<<"tsung">>},{jid,<<"user00777">>,<<"mydomain.com">>,<<>>,<<"user00777">>,<<"mydomain.com">>,<<>>}]}
2016-01-24 08:31:31.839 [error] <0.5357.0>@ejabberd_hooks:run_fold1:368 {timeout,{gen_server,call,[cache_tab_archive_prefs_1,{lookup,{<<"user003076">>,<<"mydomain.com">>},#Fun<mod_mam.9.13561693>},60000]}}
running hook: {user_send_packet,[{state,{socket_state,gen_tcp,#Port<0.18372>,<0.5356.0>},ejabberd_socket,#Ref<0.0.0.30612>,false,<<"17107910498180650440">>,undefined,c2s,c2s_shaper,false,true,false,false,[verify_none,compression_none,{protocol_options,<<"no_sslv3">>},{certfile,<<"/opt/ejabberd-16.01/conf/server.pem">>}],true,{jid,<<"user003076">>,<<"mydomain.com">>,<<"tsung">>,<<"user003076">>,<<"mydomain.com">>,<<"tsung">>},<<"user003076">>,<<"mydomain.com">>,<<"tsung">>,{{1453,611599,497289},<0.5357.0>},{1,{{<<"user003076">>,<<"mydomain.com">>,<<>>},nil,nil}},{1,{{<<"user003076">>,<<"mydomain.com">>,<<>>},nil,nil}},{1,{{<<"user003076">>,<<"mydomain.com">>,<<>>},nil,nil}},{xmlel,<<"presence">>,[{<<"id">>,<<"14079">>}],[]},{1453,611603,518372},{userlist,none,[],false},c2s,ejabberd_auth_odbc,{{192,168,120,32},37860},[{caps_resources,{0,nil}}],active,[],inactive,undefined,undefined,1000,undefined,300,300,false,0,0,<<>>},{jid,<<"user003076">>,<<"mydomain.com">>,<<"tsung">>,<<"user003076">>,<<"mydomain.com">>,<<"tsung">>},{jid,<<"user001339">>,<<"mydomain.com">>,<<>>,<<"user001339">>,<<"mydomain.com">>,<<>>}]}
2016-01-24 08:31:31.840 [error] <0.5470.0>@ejabberd_hooks:run_fold1:368 {timeout,{gen_server,call,[cache_tab_archive_prefs_1,{lookup,{<<"user001801">>,<<"mydomain.com">>},#Fun<mod_mam.9.13561693>},60000]}}
running hook: {user_send_packet,[{state,{socket_state,gen_tcp,#Port<0.18428>,<0.5469.0>},ejabberd_socket,#Ref<0.0.0.31775>,false,<<"10631203266819771091">>,undefined,c2s,c2s_shaper,false,true,false,false,[verify_none,compression_none,{protocol_options,<<"no_sslv3">>},{certfile,<<"/opt/ejabberd-16.01/conf/server.pem">>}],true,{jid,<<"user001801">>,<<"mydomain.com">>,<<"tsung">>,<<"user001801">>,<<"mydomain.com">>,<<"tsung">>},<<"user001801">>,<<"mydomain.com">>,<<"tsung">>,{{1453,611599,598137},<0.5470.0>},{1,{{<<"user001801">>,<<"mydomain.com">>,<<>>},nil,nil}},{1,{{<<"user001801">>,<<"mydomain.com">>,<<>>},nil,nil}},{1,{{<<"user001801">>,<<"mydomain.com">>,<<>>},nil,nil}},{xmlel,<<"presence">>,[{<<"id">>,<<"14067">>}],[]},{1453,611603,388402},{userlist,none,[],false},c2s,ejabberd_auth_odbc,{{192,168,120,32},51191},[{caps_resources,{0,nil}}],active,[],inactive,undefined,undefined,1000,undefined,300,300,false,0,0,<<>>},{jid,<<"user001801">>,<<"mydomain.com">>,<<"tsung">>,<<"user001801">>,<<"mydomain.com">>,<<"tsung">>},{jid,<<"user00668">>,<<"mydomain.com">>,<<>>,<<"user00668">>,<<"mydomain.com">>,<<>>}]}
2016-01-24 08:31:31.840 [info] <0.28907.2>@ejabberd_c2s:wait_for_feature_request:740 ({socket_state,gen_tcp,#Port<0.62751>,<0.28906.2>}) Accepted authentication for user0088687 by ejabberd_auth_odbc from 192.168.120.36
2016-01-24 08:31:31.841 [error] <0.5474.0>@ejabberd_hooks:run_fold1:368 {timeout,{gen_server,call,[cache_tab_archive_prefs_3,{lookup,{<<"user003199">>,<<"mydomain.com">>},#Fun<mod_mam.9.13561693>},60000]}}
running hook: {user_send_packet,[{state,{socket_state,gen_tcp,#Port<0.18430>,<0.5473.0>},ejabberd_socket,#Ref<0.0.0.31798>,false,<<"8595570831618270126">>,undefined,c2s,c2s_shaper,false,true,false,false,[verify_none,compression_none,{protocol_options,<<"no_sslv3">>},{certfile,<<"/opt/ejabberd-16.01/conf/server.pem">>}],true,{jid,<<"user003199">>,<<"mydomain.com">>,<<"tsung">>,<<"user003199">>,<<"mydomain.com">>,<<"tsung">>},<<"user003199">>,<<"mydomain.com">>,<<"tsung">>,{{1453,611599,599722},<0.5474.0>},{1,{{<<"user003199">>,<<"mydomain.com">>,<<>>},nil,nil}},{1,{{<<"user003199">>,<<"mydomain.com">>,<<>>},nil,nil}},{1,{{<<"user003199">>,<<"mydomain.com">>,<<>>},nil,nil}},{xmlel,<<"presence">>,[{<<"id">>,<<"14089">>}],[]},{1453,611603,242169},{userlist,none,[],false},c2s,ejabberd_auth_odbc,{{192,168,120,35},55028},[{caps_resources,{0,nil}}],active,[],inactive,undefined,undefined,1000,undefined,300,300,false,0,0,<<>>},{jid,<<"user003199">>,<<"mydomain.com">>,<<"tsung">>,<<"user003199">>,<<"mydomain.com">>,<<"tsung">>},{jid,<<"user006634">>,<<"mydomain.com">>,<<>>,<<"user006634">>,<<"mydomain.com">>,<<>>}]}
2016-01-24 08:31:31.841 [info] <0.28533.2>@ejabberd_c2s:wait_for_feature_request:740 ({socket_state,gen_tcp,#Port<0.62566>,<0.28532.2>}) Accepted authentication for user0079665 by ejabberd_auth_odbc from 192.168.120.30
2016-01-24 08:31:31.841 [error] <0.5432.0>@ejabberd_hooks:run_fold1:368 {timeout,{gen_server,call,[cache_tab_archive_prefs_4,{lookup,{<<"user001030">>,<<"mydomain.com">>},#Fun<mod_mam.9.13561693>},60000]}}
running hook: {user_send_packet,[{state,{socket_state,gen_tcp,#Port<0.18409>,<0.5431.0>},ejabberd_socket,#Ref<0.0.0.31381>,false,<<"3949862955910352276">>,undefined,c2s,c2s_shaper,false,true,false,false,[verify_none,compression_none,{protocol_options,<<"no_sslv3">>},{certfile,<<"/opt/ejabberd-16.01/conf/server.pem">>}],true,{jid,<<"user001030">>,<<"mydomain.com">>,<<"tsung">>,<<"user001030">>,<<"mydomain.com">>,<<"tsung">>},<<"user001030">>,<<"mydomain.com">>,<<"tsung">>,{{1453,611599,573063},<0.5432.0>},{1,{{<<"user001030">>,<<"mydomain.com">>,<<>>},nil,nil}},{1,{{<<"user001030">>,<<"mydomain.com">>,<<>>},nil,nil}},{1,{{<<"user001030">>,<<"mydomain.com">>,<<>>},nil,nil}},{xmlel,<<"presence">>,[{<<"id">>,<<"14097">>}],[]},{1453,611603,560759},{userlist,none,[],false},c2s,ejabberd_auth_odbc,{{192,168,120,31},30966},[{caps_resources,{0,nil}}],active,[],inactive,undefined,undefined,1000,undefined,300,300,false,0,0,<<>>},{jid,<<"user001030">>,<<"mydomain.com">>,<<"tsung">>,<<"user001030">>,<<"mydomain.com">>,<<"tsung">>},{jid,<<"user008051">>,<<"mydomain.com">>,<<>>,<<"user008051">>,<<"mydomain.com">>,<<>>}]}
2016-01-24 08:31:31.842 [info] <0.28916.2>@ejabberd_c2s:wait_for_feature_request:740 ({socket_state,gen_tcp,#Port<0.62755>,<0.28915.2>}) Accepted authentication for user0099955 by ejabberd_auth_odbc from 192.168.120.32
2016-01-24 08:31:31.843 [info] <0.29224.2>@ejabberd_c2s:wait_for_feature_request:767 ({socket_state,gen_tcp,#Port<0.62908>,<0.29223.2>}) Failed authentication for user00100228@mydomain.com from 192.168.120.33
2016-01-24 08:31:31.844 [error] <0.13740.0>@ejabberd_hooks:run_fold1:368 {timeout,{gen_server,call,[cache_tab_archive_prefs_2,{lookup,{<<"user0010845">>,<<"mydomain.com">>},#Fun<mod_mam.9.13561693>},60000]}}
running hook: {user_receive_packet,[{state,{socket_state,gen_tcp,#Port<0.22555>,<0.13739.0>},ejabberd_socket,#Ref<0.0.0.129529>,false,<<"7173877015512291491">>,undefined,c2s,c2s_shaper,false,true,false,false,[verify_none,compression_none,{protocol_options,<<"no_sslv3">>},{certfile,<<"/opt/ejabberd-16.01/conf/server.pem">>}],true,{jid,<<"user0010845">>,<<"mydomain.com">>,<<"tsung">>,<<"user0010845">>,<<"mydomain.com">>,<<"tsung">>},<<"user0010845">>,<<"mydomain.com">>,<<"tsung">>,{{1453,611606,254296},<0.13740.0>},{1,{{<<"user0010845">>,<<"mydomain.com">>,<<>>},nil,nil}},{1,{{<<"user0010845">>,<<"mydomain.com">>,<<>>},nil,nil}},{1,{{<<"user0010845">>,<<"mydomain.com">>,<<>>},nil,nil}},{xmlel,<<"presence">>,[{<<"id">>,<<"40900">>}],[]},{1453,611615,728824},{userlist,none,[],false},c2s,ejabberd_auth_odbc,{{192,168,120,39},1593},[],active,[],inactive,undefined,undefined,1000,undefined,300,300,false,0,0,<<>>},{jid,<<"user0010845">>,<<"mydomain.com">>,<<"tsung">>,<<"user0010845">>,<<"mydomain.com">>,<<"tsung">>},{jid,<<"user0028215">>,<<"mydomain.com">>,<<"tsung">>,<<"user0028215">>,<<"mydomain.com">>,<<"tsung">>},{jid,<<"user0010845">>,<<"mydomain.com">>,<<>>,<<"user0010845">>,<<"mydomain.com">>,<<>>}]}
2016-01-24 08:31:31.845 [error] <0.5329.0>@ejabberd_hooks:run_fold1:368 {timeout,{gen_server,call,[cache_tab_archive_prefs_3,{lookup,{<<"user002821">>,<<"mydomain.com">>},#Fun<mod_mam.9.13561693>},60000]}}
running hook: {user_send_packet,[{state,{socket_state,gen_tcp,#Port<0.18358>,<0.5328.0>},ejabberd_socket,#Ref<0.0.0.30299>,false,<<"9145861212901704113">>,undefined,c2s,c2s_shaper,false,true,false,false,[verify_none,compression_none,{protocol_options,<<"no_sslv3">>},{certfile,<<"/opt/ejabberd-16.01/conf/server.pem">>}],true,{jid,<<"user002821">>,<<"mydomain.com">>,<<"tsung">>,<<"user002821">>,<<"mydomain.com">>,<<"tsung">>},<<"user002821">>,<<"mydomain.com">>,<<"tsung">>,{{1453,611599,473252},<0.5329.0>},{1,{{<<"user002821">>,<<"mydomain.com">>,<<>>},nil,nil}},{1,{{<<"user002821">>,<<"mydomain.com">>,<<>>},nil,nil}},{1,{{<<"user002821">>,<<"mydomain.com">>,<<>>},nil,nil}},{xmlel,<<"presence">>,[{<<"id">>,<<"14106">>}],[]},{1453,611603,447097},{userlist,none,[],false},c2s,ejabberd_auth_odbc,{{192,168,120,35},47327},[{caps_resources,{0,nil}}],active,[],inactive,undefined,undefined,1000,undefined,300,300,false,0,0,<<>>},{jid,<<"user002821">>,<<"mydomain.com">>,<<"tsung">>,<<"user002821">>,<<"mydomain.com">>,<<"tsung">>},{jid,<<"user006471">>,<<"mydomain.com">>,<<>>,<<"user006471">>,<<"mydomain.com">>,<<>>}]}
2016-01-24 08:31:31.846 [error] <0.5365.0>@ejabberd_hooks:run_fold1:368 {timeout,{gen_server,call,[cache_tab_archive_prefs_3,{lookup,{<<"user003090">>,<<"mydomain.com">>},#Fun<mod_mam.9.13561693>},60000]}}
running hook: {user_send_packet,[{state,{socket_state,gen_tcp,#Port<0.18376>,<0.5364.0>},ejabberd_socket,#Ref<0.0.0.30667>,false,<<"3082964866783709463">>,undefined,c2s,c2s_shaper,false,true,false,false,[verify_none,compression_none,{protocol_options,<<"no_sslv3">>},{certfile,<<"/opt/ejabberd-16.01/conf/server.pem">>}],true,{jid,<<"user003090">>,<<"mydomain.com">>,<<"tsung">>,<<"user003090">>,<<"mydomain.com">>,<<"tsung">>},<<"user003090">>,<<"mydomain.com">>,<<"tsung">>,{{1453,611599,503417},<0.5365.0>},{1,{{<<"user003090">>,<<"mydomain.com">>,<<>>},nil,nil}},{1,{{<<"user003090">>,<<"mydomain.com">>,<<>>},nil,nil}},{1,{{<<"user003090">>,<<"mydomain.com">>,<<>>},nil,nil}},{xmlel,<<"presence">>,[{<<"id">>,<<"14104">>}],[]},{1453,611603,569881},{userlist,none,[],false},c2s,ejabberd_auth_odbc,{{192,168,120,39},42374},[{caps_resources,{0,nil}}],active,[],inactive,undefined,undefined,1000,undefined,300,300,false,0,0,<<>>},{jid,<<"user003090">>,<<"mydomain.com">>,<<"tsung">>,<<"user003090">>,<<"mydomain.com">>,<<"tsung">>},{jid,<<"user0011078">>,<<"mydomain.com">>,<<>>,<<"user0011078">>,<<"mydomain.com">>,<<>>}]}
2016-01-24 08:31:31.848 [error] <0.5339.0>@ejabberd_hooks:run_fold1:368 {timeout,{gen_server,call,[cache_tab_archive_prefs_2,{lookup,{<<"user003061">>,<<"mydomain.com">>},#Fun<mod_mam.9.13561693>},60000]}}
running hook: {user_send_packet,[{state,{socket_state,gen_tcp,#Port<0.18363>,<0.5338.0>},ejabberd_socket,#Ref<0.0.0.30371>,false,<<"16107640046174933942">>,undefined,c2s,c2s_shaper,false,true,false,false,[verify_none,compression_none,{protocol_options,<<"no_sslv3">>},{certfile,<<"/opt/ejabberd-16.01/conf/server.pem">>}],true,{jid,<<"user003061">>,<<"mydomain.com">>,<<"tsung">>,<<"user003061">>,<<"mydomain.com">>,<<"tsung">>},<<"user003061">>,<<"mydomain.com">>,<<"tsung">>,{{1453,611599,477452},<0.5339.0>},{1,{{<<"user003061">>,<<"mydomain.com">>,<<>>},nil,nil}},{1,{{<<"user003061">>,<<"mydomain.com">>,<<>>},nil,nil}},{1,{{<<"user003061">>,<<"mydomain.com">>,<<>>},nil,nil}},{xmlel,<<"presence">>,[{<<"id">>,<<"14112">>}],[]},{1453,611603,619269},{userlist,none,[],false},c2s,ejabberd_auth_odbc,{{192,168,120,37},41897},[{caps_resources,{0,nil}}],active,[],inactive,undefined,undefined,1000,undefined,300,300,false,0,0,<<>>},{jid,<<"user003061">>,<<"mydomain.com">>,<<"tsung">>,<<"user003061">>,<<"mydomain.com">>,<<"tsung">>},{jid,<<"user003018">>,<<"mydomain.com">>,<<>>,<<"user003018">>,<<"mydomain.com">>,<<>>}]}
2016-01-24 08:31:31.849 [error] <0.5136.0>@ejabberd_hooks:run_fold1:368 {timeout,{gen_server,call,[cache_tab_archive_prefs_3,{lookup,{<<"user002319">>,<<"mydomain.com">>},#Fun<mod_mam.9.13561693>},60000]}}
running hook: {user_send_packet,[{state,{socket_state,gen_tcp,#Port<0.18262>,<0.5135.0>},ejabberd_socket,#Ref<0.0.0.27100>,false,<<"13746549659166139283">>,undefined,c2s,c2s_shaper,false,true,false,false,[verify_none,compression_none,{protocol_options,<<"no_sslv3">>},{certfile,<<"/opt/ejabberd-16.01/conf/server.pem">>}],true,{jid,<<"user002319">>,<<"mydomain.com">>,<<"tsung">>,<<"user002319">>,<<"mydomain.com">>,<<"tsung">>},<<"user002319">>,<<"mydomain.com">>,<<"tsung">>,{{1453,611599,276440},<0.5136.0>},{1,{{<<"user002319">>,<<"mydomain.com">>,<<>>},nil,nil}},{1,{{<<"user002319">>,<<"mydomain.com">>,<<>>},nil,nil}},{1,{{<<"user002319">>,<<"mydomain.com">>,<<>>},nil,nil}},{xmlel,<<"presence">>,[{<<"id">>,<<"14122">>}],[]},{1453,611603,425191},{userlist,none,[],false},c2s,ejabberd_auth_odbc,{{192,168,120,32},25908},[{caps_resources,{0,nil}}],active,[],inactive,undefined,undefined,1000,undefined,300,300,false,0,0,<<>>},{jid,<<"user002319">>,<<"mydomain.com">>,<<"tsung">>,<<"user002319">>,<<"mydomain.com">>,<<"tsung">>},{jid,<<"user007054">>,<<"mydomain.com">>,<<>>,<<"user007054">>,<<"mydomain.com">>,<<>>}]}
2016-01-24 08:31:31.849 [error] <0.5436.0>@ejabberd_hooks:run_fold1:368 {timeout,{gen_server,call,[cache_tab_archive_prefs_3,{lookup,{<<"user003165">>,<<"mydomain.com">>},#Fun<mod_mam.9.13561693>},60000]}}
running hook: {user_send_packet,[{state,{socket_state,gen_tcp,#Port<0.18411>,<0.5435.0>},ejabberd_socket,#Ref<0.0.0.31429>,false,<<"12382523486411929322">>,undefined,c2s,c2s_shaper,false,true,false,false,[verify_none,compression_none,{protocol_options,<<"no_sslv3">>},

Apparently they are timeouts

Apparently they are timeouts when looking information in the MAM table, when different users login. It seems the MAM service cannot handle the amount of requests you send.

How to fix it?

I guess disable mod_mam, or improve its source code efficiency, or restrict your clients to be less aggresive regarding MAM, or improve the machine capabilities (I don't know if the bottleneck is the CPU, RAM or disk).

thanks. if I disable always

thanks. if I disable always and enable roster, will it help me(performance)?
roster's option need query (select) before insert to archive table, which one is better roster or always(performance)?

mod_mam:
    default: always
    cache_size: 1000
    cache_life_time: 3600

or

mod_mam:
    default: roster
    cache_size: 1000
    cache_life_time: 3600
Syndicate content