1

I am not sure what approach to follow for Akka supervision.

I have an Akka actor that lists files from a FTP server when a message triggers it. If the connection is broken, the actor will fail with an exception (say, IOException) which will trigger supervision. At this point, I see two alternatives:

  • I keep resuming / restarting the actor until the server comes back up, maybe with an exponential backoff
  • I set parameters (such as maxNrOfRetries = xy) in a way that the supervisor will give up and stop the actor after xy times

The first strategy seems wasteful, but the second one seems to bring another issue: how would the actor be eventually restarted? I have the feeling that tuning the parameters of the Backoff supervisor is the best way to go, but maybe I'm missing something?

ticofab
  • 7,551
  • 13
  • 49
  • 90
  • I'm not sure I understand the question. Both policies seem valid in certain contexts, it really depends of what you want to achieve. The main point of decision is what is waiting the answer ? Is it relevant to answer in 10 minutes ? 10 hours ? If it's an http client, giving up seems right e.g. – C4stor Nov 04 '16 at 15:58

1 Answers1

0

If you need to restart the actor eventually without knowing when the connection will be up again, exponential backoff (with an upper limit of say 60 seconds?) seems reasonable.

This way you have a fast reconnect if the connection is just lost for a few seconds and with the back off your not wasting resources. The upper limit on the backoff sets the maximum time your actor is offline even though the connection might be back up.

Erik
  • 2,888
  • 2
  • 18
  • 35