Circuit breaker design pattern: Difference between revisions

Content deleted Content added
added a PHP implementation
Line 5:
'''Circuit breaker''' is a [[Design pattern (computer science)|design pattern]] used in modern [[software 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.
 
==Common Usesuses==
 
Assume that an application connects to a [[database]] 100 times per second and the database fails. The application designer does not want to have the same error reoccur constantly. They also want to handle the error quickly and gracefully without waiting for [[TCP connection]] timeout.
Line 23:
Before the external service is used from the application, the storage layer is queried to retrieve the current state.
 
==Performance Implicationimplication==
 
While it's safe to say that the benefits outweigh the consequences, implementing Circuit Breaker will negatively affect the performance.
Line 29:
By how much depends on the storage layer used and generally available resources. The largest factors in this regard are the type of cache, for example, disk-based vs. memory-based and local vs. network.
 
==Example Implementationimplementation==
 
===PHP===