awolden / brakes

Hystrix compliant Node.js Circuit Breaker Library
MIT License
300 stars 35 forks source link

Open circuit based on number of failures the last n ms, not n requests #50

Closed SimenB closed 7 years ago

SimenB commented 7 years ago

We'd like to have a sliding window being checked for percentage of failures, instead of a definite number of requests. Levee has this, for instance. Any particular reason why this is not implemented here? Would you be opposed to a PR adding it?

E.g. There is more than 25% failures the last second, open the circuit.

jquatier commented 7 years ago

This is how it works already, by setting bucketNum, bucketSpan, and threshold.

Levee only supports maxFailures, and isn't percentage based.

SimenB commented 7 years ago

Hmm, I tried that, but was unable to make it open. I'll try again tomorrow, thanks!

On Mon, 3 Oct 2016, 16:59 Jacob Quatier, notifications@github.com wrote:

This is how it works already, by setting bucketNum, bucketSpan, and threshold.

Levee only supports maxFailures, and isn't percentage based.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/awolden/brakes/issues/50#issuecomment-251129901, or mute the thread https://github.com/notifications/unsubscribe-auth/ABVvihT6wHDYvzkdONP-RkcMyEg3oBmjks5qwRhAgaJpZM4KMjEV .

Simen Bekkhus

awolden commented 7 years ago

You might be running into an issue with the waitThreshold option. Brakes waits a given # of requests before monitoring the health of the circuit. This is present to avoid immediately tripping the circuit if the first request fails. The default for waitThreshold is 100, which is probably high for lower traffic environments.

SimenB commented 7 years ago

Yeah, I can see it working. I just wasn't able to follow the code. Thanks!