Circuit breaker reset based upon number of failures within a time window.

59 views
Skip to first unread message

Sandeep Khurana

unread,
Oct 1, 2015, 5:35:15 AM10/1/15
to Akka User List
Hello All

I am evaluating Akka to use in our enterprise application. One of the feature which we are looking for is to find out if we can allow circuit  breaker to remain closed when the number of failures are less than certain threshold within a time window.

For example, 

If in 30 minutes number of failures are more than 10 then open the circuit breaker but if not then reset the failure count to zero back again so that for next 30 mins the failure count restarts from zero .

In more details,  if the application starts at 12 AM and  and by 12.30 only 9 failures were encountered. Then immediately after 12.30 the failure count resets to zero and allow 10 or less failure for next 30 mins again without opening the circuit breaker. However if the failure count is 11 then circuit breaker open (and enters half open stage after reset time interval) .

If its not present in Akka then can this be implemented over Akka as part of the application itself?

Viktor Klang

unread,
Oct 1, 2015, 5:41:19 AM10/1/15
to Akka User List
I might be wrong, but isn't this what this constructor does?

http://doc.akka.io/api/akka/2.4.0/index.html#akka.pattern.CircuitBreaker@<init>(scheduler:akka.actor.Scheduler,maxFailures:Int,callTimeout:scala.concurrent.duration.FiniteDuration,resetTimeout:scala.concurrent.duration.FiniteDuration)(implicitexecutor:scala.concurrent.ExecutionContext):akka.pattern.CircuitBreaker

--
>>>>>>>>>> Read the docs: http://akka.io/docs/
>>>>>>>>>> Check the FAQ: http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
---
You received this message because you are subscribed to the Google Groups "Akka User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to akka-user+...@googlegroups.com.
To post to this group, send email to akka...@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.



--
Cheers,

Patrik Nordwall

unread,
Oct 2, 2015, 10:42:27 AM10/2/15
to akka...@googlegroups.com
On Thu, Oct 1, 2015 at 11:40 AM, Viktor Klang <viktor...@gmail.com> wrote:
I might be wrong, but isn't this what this constructor does?

http://doc.akka.io/api/akka/2.4.0/index.html#akka.pattern.CircuitBreaker@<init>(scheduler:akka.actor.Scheduler,maxFailures:Int,callTimeout:scala.concurrent.duration.FiniteDuration,resetTimeout:scala.concurrent.duration.FiniteDuration)(implicitexecutor:scala.concurrent.ExecutionContext):akka.pattern.CircuitBreaker

I think the resetTimeout is only for how long it should remain in Open before it goes to HalfOpen.

The failure count in Closed is reset to 0 immediately when there is one successful call. 

/Patrik



--

Patrik Nordwall
Typesafe Reactive apps on the JVM
Twitter: @patriknw

Sandeep Khurana

unread,
Oct 5, 2015, 12:59:32 AM10/5/15
to Akka User List
But what I am looking for is to allow failures within a time window and if # of failures are less than threshold then keep working and reset that count to zero after that threshold.

Patrik Nordwall

unread,
Oct 5, 2015, 2:19:41 AM10/5/15
to akka...@googlegroups.com
On Mon, Oct 5, 2015 at 6:34 AM, Sandeep Khurana <skhur...@gmail.com> wrote:
But what I am looking for is to allow failures within a time window and if # of failures are less than threshold then keep working and reset that count to zero after that threshold.

I think it can be an interesting contribution. I suggest that you try it out and then contribute back to Akka with a pull request.
Regards,
Patrik
Reply all
Reply to author
Forward
0 new messages