Hi Zvi, <div>It would be useful if you can use <a href="http://www.erlang.org/doc/man/eprof.html">eprof</a> to get some measurements about how time is spent, is it really in starting the timer or something else.</div><div>
<br><div class="gmail_quote">On Tue, Nov 22, 2011 at 1:02 PM, Zvi <span dir="ltr"><<a href="mailto:zvi.avraham@gmail.com">zvi.avraham@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Hi,<br>
<br>
I'll try to add more info to Ori's post (we work together).<br>
<br>
The code of our tests is public:<br>
<br>
1. The version with timer per process (maximum we can get ~ 370K<br>
concurrent connections out of 500K):<br>
<a href="https://github.com/nivertech/cowboy/blob/ori_acceptor_rate_throttling_141111/test/simple_ws_server.erl" target="_blank">https://github.com/nivertech/cowboy/blob/ori_acceptor_rate_throttling_141111/test/simple_ws_server.erl</a><br>

<br>
2. The version with single timer - broadcasting idle message to all<br>
per-connection processes (no problems - we can get 500K  concurrent<br>
connections out of 500K):<br>
<a href="https://github.com/nivertech/cowboy/blob/ori_acceptor_rate_throttling_141111/test/simple_ws_server2.erl" target="_blank">https://github.com/nivertech/cowboy/blob/ori_acceptor_rate_throttling_141111/test/simple_ws_server2.erl</a><br>

<br>
We also tried variation of [1] but with hibernate - same results.<br>
Both demos started using variation of go.sh script:<br>
<a href="https://github.com/nivertech/cowboy/blob/ori_acceptor_rate_throttling_141111/test/go.sh" target="_blank">https://github.com/nivertech/cowboy/blob/ori_acceptor_rate_throttling_141111/test/go.sh</a><br>
<br>
The solution with single timer is not good for us, because the<br>
broadcast itself may take some time (seconds even using high<br>
priority). Also we have application-level timers in almost every<br>
gen_server in  our codebase.<br>
<br>
Right now we experimenting with creating our own timer service, which<br>
will reuse one timer for groups of processes.<br>
<br>
So the interesting question is, how timers implemented inside BEAM /<br>
stdlib and what's effective way to replace them.<br>
Do timers implemented using processes?<br>
<br>
Thanks in advance,<br>
Zvi<br>
<div class="im"><br>
On Nov 22, 12:58 pm, Ahmed Omar <<a href="mailto:spawn.th...@gmail.com">spawn.th...@gmail.com</a>> wrote:<br>
> Hi Ori,<br>
> Can you be a bit more specific how it hurts your performance? Is there only<br>
> one process responsible for creating timers? What does your app do in the<br>
> first place?<br>
><br>
><br>
><br>
><br>
><br>
><br>
><br>
><br>
><br>
</div><div class="im">> On Tue, Nov 22, 2011 at 2:32 AM, ori brost <<a href="mailto:oribr...@gmail.com">oribr...@gmail.com</a>> wrote:<br>
> > I tried hibernation alone and it did not help, only<br>
> > hibernationcombined with reducing timer amount did the trick<br>
</div><div class="im">> > On Mon, Nov 21, 2011 at 9:25 PM, Joel Reymont <<a href="mailto:joe...@gmail.com">joe...@gmail.com</a>> wrote:<br>
> > > Are you sure that creating these timers is what's hurting performance?<br>
><br>
> > > My bet is on your processes, try hibernating them.<br>
><br>
> > > Let us know if that helps.<br>
><br>
> > > On Nov 21, 2011, at 7:22 PM, ori brost wrote:<br>
><br>
> > >> We have an erlang program which creates many (300000) timers using<br>
> > >> erlang:start_timer. We have noticed in tests that creating these<br>
> > >> timers hurts our performance. For each such timer we have a process<br>
> > >> that gets a message from it once every 25 seconds, except for waiting<br>
> > >> for these messages, the processes are mostly idle. We are working on<br>
> > >> reducing the number of timers, but we would also like to know whether<br>
> > >> these timers may hurt performance less if the processes would<br>
> > >> hibernate until they get a message. Furthermore, is there any<br>
> > >> documentation explaining why creating many timers can hurt erlang<br>
> > >> performance?<br>
><br>
> > --------------------------------------------------------------------------<br>
> > > - for hire: mac osx device driver ninja, kernel extensions and usb<br>
> > drivers<br>
><br>
> > ---------------------+------------+---------------------------------------<br>
> > ><a href="http://wagerlabs.com" target="_blank">http://wagerlabs.com</a>| @wagerlabs |<br>
> ><a href="http://www.linkedin.com/in/joelreymont" target="_blank">http://www.linkedin.com/in/joelreymont</a><br>
><br>
> > ---------------------+------------+---------------------------------------<br>
><br>
> > _______________________________________________<br>
> > erlang-questions mailing list<br>
</div>> > <a href="mailto:erlang-questi...@erlang.org">erlang-questi...@erlang.org</a><br>
<div class="im">> ><a href="http://erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
><br>
> --<br>
> Best Regards,<br>
</div>> - Ahmed Omarhttp://<a href="http://nl.linkedin.com/in/adiaa" target="_blank">nl.linkedin.com/in/adiaa</a><br>
> Follow me on twitter<br>
> @spawn_think <<a href="http://twitter.com/#!/spawn_think" target="_blank">http://twitter.com/#!/spawn_think</a>><br>
><br>
> _______________________________________________<br>
> erlang-questions mailing list<br>
> erlang-questi...@erlang.orghttp://<a href="http://erlang.org/mailman/listinfo/erlang-questions" target="_blank">erlang.org/mailman/listinfo/erlang-questions</a><br>
<div class="HOEnZb"><div class="h5">_______________________________________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br>Best Regards,<br>- Ahmed Omar<div><a href="http://nl.linkedin.com/in/adiaa" target="_blank">http://nl.linkedin.com/in/adiaa</a></div><div>Follow me on twitter</div>
<div><a href="http://twitter.com/#!/spawn_think" target="_blank">@spawn_think</a></div><br>
</div>