gobreaker icon indicating copy to clipboard operation
gobreaker copied to clipboard

Why don't use a rolling window to maintain the counts?

Open spacewander opened this issue 6 years ago • 5 comments

I just give a quite look to this library. This circuit breaker is mighty simple (compared with a Hystrix-like implementation) but still powerful.

However, I have a question about the counter expiration. Hystrix uses a rolling window to store the counts. This library doesn't maintain a rolling window, instead it drops the whole counts when the time interval is passed.

There may be a problem. Considered we use 10s as an interval, and we have 10000 requests come between 1s ~ 11s, 1000 requests per each second. The last 900 requests fail in the 11s. If the rolling window is used, the error rate will be 9% (900 / 10000). However, if we are unfortunate enough that the counts are expired in 10s, the error will be 90%, since we will recount the requests from the 11s.

Maybe I am missing something. Please let me know if I am wrong.

spacewander avatar Apr 20 '19 10:04 spacewander

I think your proposal makes sense. I'm considering the rolling window feature.

YoshiyukiMineo avatar Apr 23 '19 07:04 YoshiyukiMineo

@YoshiyukiMineo do you have some plans when you can implement it?

vtolstov avatar May 28 '19 21:05 vtolstov