3

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?

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.

  • 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: stackoverflow.com/questions/46800163/… – Zalastax Sep 28 '18 at 14:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.