Urgent.News

the world's headlines, one feed

Editions

Tech

What Is the Circuit Breaker Pattern? A Practical Guide

What Is the Circuit Breaker Pattern? A Practical Guide for Developers Imagine your application depends on a payment service. Everything works normally until the payment service starts responding slowly. Your application keeps sending requests, each request waits longer than usual, and eventually more requests start piling up. Now imagine this happening across several services at the same time.…

The Circuit Breaker pattern is a software design technique used to prevent an application from repeatedly calling a service that is currently unhealthy or failing. It functions like an electrical circuit breaker, cutting the connection to the failing service to prevent further damage and give it time to recover.

In modern applications, systems often rely on multiple interconnected services. If one service fails, it can lead to a cascade of problems affecting other services. This is known as a cascading failure. For instance, if a Payment Service becomes unavailable, the Order Service may experience timeouts, increased latency, and ultimately, an unstable application.

The Circuit Breaker pattern addresses this issue by monitoring the health of dependent services and temporarily stopping requests when they begin to fail. It does this by transitioning through three states: Closed, Open, and Half-Open.

In the Closed state, requests are allowed to reach the dependency. The circuit breaker monitors metrics such as failed requests, successful requests, timeouts, and error percentages. If the failure rate exceeds a pre-defined threshold (e.g., 50%), and the number of requests reaches a minimum (e.g., 20), the circuit breaker transitions to the Open state.

In the Open state, no requests are sent to the failing dependency. Instead, the circuit breaker returns a fast failure response or fallback immediately. This prevents the application from wasting resources waiting for an unhealthy service that is already known to be broken.

Once the configured recovery period elapses, the circuit breaker moves to the Half-Open state. During this state, the circuit breaker allows a small number of test requests to be sent to the service. If the service responds successfully, the circuit breaker closes, and normal traffic resumes. However, if the test request fails again, the circuit breaker reopens the circuit, returning to the Open state.

This half-open state helps determine if the service has recovered and is ready to handle traffic again without flooding it with requests.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — it may contain errors, so check the original before relying on it.

Read the original at dev.to →

More in Tech

Samsung SDI to Take Full Control of U.S. Battery Plant

Samsung SDI will take full ownership of a battery manufacturing plant in Indiana as it restructures its partnership with General Motors, while continuing joint development of next-generation batteries…

  • Samsung SDI to fully acquire Indiana battery plant from GM.
  • Joint venture Synergy Cells to be fully owned by Samsung SDI.
  • Plant to produce next-gen EV batteries and ESS batteries.

Beyond Words: Tracking Depression Risk Trends Using Wav2Vec 2.0 and FastAPI 🧠🎙️

Mental health is often hidden not in what we say, but in how we say it. As developers, we've spent years perfecting Speech-to-Text (STT), but the real frontier of Affective Computing lies in analyzing…

  • Wav2Vec 2.0 analyzes prosody, pitch, and rhythm in voice recordings to track depression risk.
  • FastAPI creates secure backend for real-time audio processing and JSON risk score responses.
  • System prioritizes user privacy by maintaining raw audio format throughout analysis.

Every newsletter tool hands you an email address. That address is the lock-in.

Every newsletter tool I've looked at hands you an email address. Meco gives you something like edward@mecoinbox.com and tells you to "use this email to subscribe to any new newsletters that you want…

  • Every newsletter tool assigns a unique email address for subscriptions.
  • Subscriptions are stored in multiple publisher databases keyed by the provided email address.
  • Using a forwarding address allows easy switching of newsletter tools.