# Design Patterns for Microservices — Circuit Breaker Pattern ![rw-book-cover](https://readwise-assets.s3.amazonaws.com/static/images/article0.00998d930354.png) URL:: https://medium.com/nerd-for-tech/design-patterns-for-microservices-circuit-breaker-pattern-ba402a45aac2 Author:: Nisal Pubudu ## Highlights > In Microservices architecture, a service usually calls other services to retrieve data, and there is the chance that the downstream service may be down. ([View Highlight](https://instapaper.com/read/1435355987/17160733)) > It may be cause by slow network connection, timeouts, or temporal unavailability. Therefore, retrying calls can solve the issue. However, if there is a severe issue on a particular microservice, then it will be unavailable for a longer time. In such case, the request will be continuously sent to that service, since the client doesn’t have any knowledge about a particular service being down. As a result, the network resources will be exhausted with low performance and bad user experience. Also, the failure of one service might lead to Cascading failures throughout the application. > Therefore, you can use the Circuit Breaker Design Pattern to overcome this problem. ([View Highlight](https://instapaper.com/read/1435355987/17167641)) > With the help of this pattern, the client will invoke a remote service through a proxy. This proxy will basically behave as an electrical circuit breaker. So, when the number of failures crosses the threshold number, the circuit breaker trips for a particular time period. Then, all the attempts to invoke the remote service will fail within this timeout period. After the timeout expires, the circuit breaker allows a limited number of test requests to pass through it. If those requests succeed, the circuit breaker resumes back to the normal operation. Otherwise, if there is a failure, the timeout period begins again. ([View Highlight](https://instapaper.com/read/1435355987/17167644)) --- Title: Design Patterns for Microservices — Circuit Breaker Pattern Author: Nisal Pubudu Tags: readwise, articles date: 2024-01-30 --- # Design Patterns for Microservices — Circuit Breaker Pattern ![rw-book-cover](https://readwise-assets.s3.amazonaws.com/static/images/article0.00998d930354.png) URL:: https://medium.com/nerd-for-tech/design-patterns-for-microservices-circuit-breaker-pattern-ba402a45aac2 Author:: Nisal Pubudu ## AI-Generated Summary None ## Highlights > In Microservices architecture, a service usually calls other services to retrieve data, and there is the chance that the downstream service may be down. ([View Highlight](https://instapaper.com/read/1435355987/17160733)) > It may be cause by slow network connection, timeouts, or temporal unavailability. Therefore, retrying calls can solve the issue. However, if there is a severe issue on a particular microservice, then it will be unavailable for a longer time. In such case, the request will be continuously sent to that service, since the client doesn’t have any knowledge about a particular service being down. As a result, the network resources will be exhausted with low performance and bad user experience. Also, the failure of one service might lead to Cascading failures throughout the application. > Therefore, you can use the Circuit Breaker Design Pattern to overcome this problem. ([View Highlight](https://instapaper.com/read/1435355987/17167641)) > With the help of this pattern, the client will invoke a remote service through a proxy. This proxy will basically behave as an electrical circuit breaker. So, when the number of failures crosses the threshold number, the circuit breaker trips for a particular time period. Then, all the attempts to invoke the remote service will fail within this timeout period. After the timeout expires, the circuit breaker allows a limited number of test requests to pass through it. If those requests succeed, the circuit breaker resumes back to the normal operation. Otherwise, if there is a failure, the timeout period begins again. ([View Highlight](https://instapaper.com/read/1435355987/17167644))