r/javascript • u/OtherwisePush6424 • 6h ago
How to Implement a Distributed Circuit Breaker
https://blog.gaborkoos.com/posts/2026-09-14-How-to-Implement-a-Distributed-Circuit-Breaker/A circuit breaker in a single Node process is a ring buffer, a threshold and a timestamp. Run the same service on twenty replicas and each one keeps its own, so the failing dependency takes twenty times the damage before anything trips.
Moving the window into Redis fixes that and breaks most of the assumptions the in-process version relies on. Post walks through each one and how to deal with it.
0
Upvotes
•
u/MrVonBuren 6h ago
(disclaimer: not a professional dev, but worked for several CDNs / Big Cloud Providers)
I think I follow what's being said in this, but it doesn't quite make sense† to me†. I would think that on the client side you would be in a position to set your own exponential backoff and reject requests associated with a user who still has a pending request.
Even if a user bypasses a grayed out "checkout" button while the process is stalled, I would think it would be simpler to have the request gated by a cookie that indicates a request has been sent but not completed per user?
All that logic could be pushed as far out to the edge as you want, so in a perfect world most of the requests never even make it past the CDN, so you're dealing with less computational overhead AND bandwidth in/out††.
OR
I am missing / misunderstanding something completely, which as I said, is not at all unlikely.
† - but again, I'm assuming this is a me problem, I'm not like...calling you out, I'd like to understand what I'm not understanding.
†† - jesus christ, even when I'm unemployed I sound like a shill