5

I need to create a distributed application with timers / periodically checking two timestamps for elapsed time. Is it possible to achieve following behaviour with the actor model:

  1. Spawn Child actor
  2. Send Message to Child actor to start the routine for checking the timestamps
  3. Do something when timer expires without receiving any messages which could work as a trigger

Incoming messages can change the timestamp which will be checked periodically.

In case of failure the supervisor needs to restore failed actors with the last two received timestamps. A slight delay (restarting actor and reapplying state) in executing the event triggered by the timer is acceptable.

The mission critical goal is to not lose any events which should've occured on a certain elapsed time between two timestamps and eliminate single point of failure at all costs.

Is the actor model (implemented with Erlang or AKKA) a good fit for solving this problem? If not what are other models/systems which are better suited for this case?

Towen
  • 59
  • 2

1 Answers1

1

There is nothing fundamentally problematic with using the actor model for this and supervision is very helpful in creating stable distributed systems. With that said, you still have to design the system to fulfill your requirements. E.g. you need to decide if you want at most once or at least once delivery. To implement this in Erlang you should look at the timer module.

Zalastax
  • 111
  • 3
  • I just need the at least once delivery. It is acceptable to get a message twice in rare cases. Is the timer module an extra actor or can it live inside an actor? – Towen Sep 27 '18 at 21:10
  • The timer module is an extra actor but it runs locally. The timer actor can become overloaded so you might want to use send_after instead: https://stackoverflow.com/questions/46800163/are-erlangsend-after-3-and-timersend-after-3-intended-to-behave-differently – Zalastax Sep 28 '18 at 14:35