Hello,
I've got a question about circuit breaker in hystrix. Please tell me if my doubts are correct or not.
When a hystrix command throws an exception from run() method, the event counts against failure metrics. If the error occurs "often enough" the circuit breaker finally trips the circuit and all subsequent command invocations will fail immediately (for some time, until the circuit is closed again).
I'm wondering if this mechanism can be abused to perform a DOS attack. Let's say that an attacker, for instance, finds a way to trigger a NullPointerException in the command (or any other error eg. by passing special combination of parameters to a web-service which uses hystrix command).
Then by repeating the request constantly, the circuit will get tripped and remain open "cutting off" *all* legitimate users from accessing the target resource, which results in a DOS. Is that correct?
What can be done in the code to mitigate this? One of solutions is to let out only those exceptions from HystrixCommand.run() method which are *really* known to be external system failures and catch and silence everything else, for instance, using HystrixBadRequestException (ie. catch(Exception e) { throw HystrixBadRequestException(e); } in almost every command). Is this the way how real-life commands should be implemented?
Regards,
Adam Dyga