<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Dalganjan Sengar on Medium]]></title>
        <description><![CDATA[Stories by Dalganjan Sengar on Medium]]></description>
        <link>https://medium.com/@dalganjan.sengar?source=rss-b8cba62e1009------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*CJaLeRNmWTEYDHLyVBEvVg.jpeg</url>
            <title>Stories by Dalganjan Sengar on Medium</title>
            <link>https://medium.com/@dalganjan.sengar?source=rss-b8cba62e1009------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 04:08:55 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@dalganjan.sengar/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[What is Circuit Breaker? Why do we need it?]]></title>
            <link>https://blog.devgenius.io/what-is-circuit-breaker-why-do-we-need-it-f0ce20e386e0?source=rss-b8cba62e1009------2</link>
            <guid isPermaLink="false">https://medium.com/p/f0ce20e386e0</guid>
            <category><![CDATA[microservices]]></category>
            <category><![CDATA[circuit-breaker]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[microservice-architecture]]></category>
            <dc:creator><![CDATA[Dalganjan Sengar]]></dc:creator>
            <pubDate>Wed, 10 Jun 2020 07:37:58 GMT</pubDate>
            <atom:updated>2020-06-11T08:17:34.396Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>The circuit breaker</strong> is a design pattern used in modern <strong>software</strong> development. It is used to detect failures and encapsulates the logic of preventing a failure from constantly recurring, during maintenance, temporary external system failure, or unexpected system difficulties.</p><p>The intent of the Circuit Breaker pattern is to handle the long-lasting transient faults. The idea behind this pattern is that we will wrap the service calls in a circuit breaker.</p><ul><li>If the number of retry failures reaches above a certain threshold value, we will make this circuit as OPEN, which means the service is not available at the time.</li><li>Once the circuit reaches the OPEN state, further calls to the service will immediately return failure to the caller instead of executing our retry logic.</li><li>This circuit breaker will have some timeout period after which it will move to the HALF-OPEN state. In this state, it will allow a service call that will determine if the service has become available or not.</li><li>If the service is not available it goes back to OPEN state.</li><li>If the service becomes available after this timeout, the circuit breaker moves to the CLOSED state.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/620/1*jxoPWIFEYWWJN2ItGe1RMg.png" /></figure><p>There could be various reasons for using the circuit breaker pattern while developing an application. Here I have listed some causes &amp; their solutions.</p><p><strong><em>Transient Failures<br></em></strong>Transient failures are the failures that occur while communicating with the external component or service and that external service is not available. This unavailability or failure to connect is not due to any problem in the service, but due to some reasons like network failure or server overload. Such issues are ephemeral. If we call the service again, chances are that our call will succeed. Such failures are called transient failures.</p><blockquote><strong>Retry Pattern<br></strong>Once we have identified the fault as a transient fault, we need to put some retry logic so that the issue will get resolved simply by calling the service again. The typical way to implement the retry is as follows:</blockquote><blockquote>1. Identify if the fault is a transient fault.<br>2. Define the maximum retry count.<br>3. Retry the service call and increment the retry count.<br>4. If the calls succeed, return the result to the caller.<br>5. If we are still getting the same fault, keep retrying until the maximum retry count is hit.<br>6. If the call is failing even after maximum retries, let the caller module know that the target service is unavailable.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1008/1*mfMcFwSuKiCJm2LEZUNWdA.png" /><figcaption>Retry Pattern</figcaption></figure><blockquote>BUT BACKOFF!!!!!</blockquote><blockquote>Let’s imagine a scenario where the transient fault is happening because the service is overloaded or some throttling is implemented at the service end. There could be a possibility that our retry requests are further adding to the overload of the busy service, which would mean that if there are multiple instances of our applications retrying for the same service, the service will be in the overloaded state longer and will take longer to recover from this state.</blockquote><blockquote>The idea behind using <strong>exponential backoff </strong>with retry is that instead of retrying after waiting for a fixed amount of time, we increase the waiting time between retries after each retry failure. So with exponential backoff, our retry algorithm will look like the following:</blockquote><blockquote>1. Identify if the fault is a transient fault.</blockquote><blockquote>2. Define the maximum retry count.</blockquote><blockquote>3. Retry the service call and increment the retry count.</blockquote><blockquote>4. If the calls succeed, return the result to the caller.</blockquote><blockquote>5. If we are still getting the same fault, Increase the delay period for the next retry.</blockquote><blockquote>6. Keep retrying and keep increasing the delay period until the maximum retry count is hit.</blockquote><blockquote>7. If the call is failing even after maximum retries, let the caller module know that the target service is unavailable.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/370/1*kYDgUIW9BY-AL_0LpavKzA.png" /></figure><blockquote><strong><em>Exponential backoff</em></strong> affects the retry algorithm and makes it more resilient.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/958/1*0kiVgJjkb9Mzxz0FWhfBng.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f0ce20e386e0" width="1" height="1" alt=""><hr><p><a href="https://blog.devgenius.io/what-is-circuit-breaker-why-do-we-need-it-f0ce20e386e0">What is Circuit Breaker? Why do we need it?</a> was originally published in <a href="https://blog.devgenius.io/">Dev Genius</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>