[erlang-questions] Erlang Scheduler for Recurring Events

Joseph Wayne Norton norton@REDACTED
Thu Aug 25 13:39:43 CEST 2011


For reference and/or comparison purposes, this timer implementation might be helpful to you:

https://github.com/hibari/gdss-brick/blob/master/src/brick_itimer.erl

The OTP timer implementation didn't scale beyond several hundred timers.

thanks,

On 2011/08/25, at 20:27, Jesper Louis Andersen wrote:

> On Wed, Aug 24, 2011 at 13:51, Hank Knight <hknight555@REDACTED> wrote:
>> Hello,
>> 
>> I need to scheduler a number of recurring events using Erlang.  Some
>> events need to be triggered every second, some every three seconds and
>> some every minute.  Any simple advise on how to do this or what tools
>> to do?
> 
> My solution would be to use erlang:send_after(..) to set up a timer
> and then set the timer again whenever it triggers. The "timer" module
> is also there, but it is considerably less effective if you end up
> with many timers (according to the performance guide -
> http://www.erlang.org/doc/efficiency_guide/commoncaveats.html#id58959).
> 
> If you have lots and lots of these timers, and your naive approach
> hits performance problems, then perhaps a trick from operating system
> kernels can be tried. The idea is that you lag the timer. Rather than
> waiting exactly three seconds, you wait 3 seconds or more, until the
> next time slot trigger for the event. That means a 3 sec timer takes
> somewhere between 3 and 6 seconds and a 1 minute timer takes between 1
> and 2 minutes. It allows you to bundle up large number of events on
> the same timer, which could be faster in some situations.
> 
> On the other hand, Erlangs internal timer stuff is pretty fast
> already, so only begin playing with it when the basic implementation
> can't cope.
> -- 
> J.
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions

Joseph Wayne Norton
norton@REDACTED






More information about the erlang-questions mailing list