3 ms·
I came to think of circuit breakers as a crude tool that has a very limited set of uses, much smaller than what it's used for. It might work as a last resort, b
by rbanffy 3y ago
I came to think of circuit breakers as a crude tool that has a very limited set of uses, much smaller than what it's used for. It might work as a last resort, but it should never be deployed as your first way to deal with failures.
If at all possible, APIs should communicate server health status back to their clients, and clients should have ways to deal with partial outages of supporting services and systems.
Also, that sequence diagram should have been a state diagram. Don't people teach proper UML in schools these days?
- bsaul 3y agoI had the same problem understanding the state diagram but didn’t even realize he used the wrong type of UML diagram :))
- brodouevencode 3y agoUML is taught, sometimes, but once you get into the industry it is a coin flip as to whether or not it is properly used - if it is used at all.
- jerf 3y agoI would think the first resort in most of the non-flooding-related cases[1] is backpressure. If you've got too many requests coming in, be sure that internally you start parking the excess incoming requests in some low-resource-usage configuration (e.g., simply noting the incoming TCP connection but then not even read()ing from it until you are ready), and let the system push back naturally by the way its latency increases. This obviously naturally pairs with both client-side and server-side timeouts, giving both a vote in how long they're willing to wait. This is generally what you want. Actively breaking the connections if I think I'm overloaded is only something I'd add if there is some additional constraint on the system that suggests it's a good idea due to some specific local concerns. Circuit breaking produces a much sharper (for lack of a better term) performance graph, where instead of degrading gracefully like backpressure will, you suddenly start getting active failures. I've built a lot of backpressure in my systems; I'm yet to need a circuit breaker. YMMV, of course, but I see some people referring to it as a basic tool and I would disagree; the basic tool is backpressure. [1]: Flooding is its own thing. In general, to weather DOS attacks but still have the service functional requires another system or likely set of systems in front of the service that can handle the DOS issues. I say this just to point out that circuit breakers aren't really for this case, because no system can on its own handle a full-on DOS flood, no matter what code you write, when the DOS flood may literally be coming in at a speed where it is faster than you can even reject connections, let alone do any work.
- vault_ 3y agoYeah, I don't think circuit breakers are really the appropriate choice in most of the situations the article is describing. Rate limiting and backpressure seem like better options most of the time. The way I see it, circuit breakers are safety devices. They're for when you need to keep a system in a safe control region and are wiling to sacrifice some reliability in order to achieve that. e.g. preventing customers from accidentally turning your globally distributed whatever into a DDOS platform or limiting the blast radius when infrastructure automation decides it should delete everything.
- rbanffy 3y agoOh yes! I used response times as a proxy for backend health a couple times. Still, it's better if the service tells you there is some degradation in a way the client can understand and handle. Sometimes, only some of the requests need to be slowed down or paused, leading to some limited functionality but not a complete loss of service.
- AtlasBarfed 3y agoYeah, they kind of are really liked ... by the service maintainers who don't have to do the front end work to tell the bad news. The article seems to gloss over that part, which is understandable, because it's probably targeted at... service coders. So how does this work on the front end? One way or another you're communicating to the user that the company/service isn't up to their expectations, SLA be damned. It also gets into the classic issue of queuing requests and dedicating resources. Imagine this: you have 100 customers, but 10% of them take 5-10x longer to serve than the others. This is pretty common. Like airline checkin or border crossings, some people will take 2 minutes, some 20 minutes. But... if you don't have any way of keeping a service handler dedicated to fast queries, all the slow bombs will saturate your workers. So even though one or tow of five service workers could service 80% of the work load quickly, if you can't identify the fast requests from the slow ones and keep a fast track for the fast ones, you're service descends to a response time of handling the worse cases (assuming they are frequent just... enough). Circuit breaking doesn't really help that.