此内容没有您所选择的语言版本。

Chapter 1. Introduction to the circuit breaker add-on for Red Hat build of Node.js


Red Hat provides a circuit breaker add-on for Red Hat build of Node.js, which is a fully supported implementation of the open source Opossum module. Opossum is a Node.js module developed by the NodeShift project team to provide circuit breaker functionality. You can use the circuit breaker add-on in your Node.js applications to ensure that application failures are monitored and handled appropriately.

Note

In the subsequent sections of this document, the term "circuit breaker" refers to the circuit breaker add-on for Red Hat build of Node.js.

The circuit breaker add-on helps to reduce the impact of failures on service architectures, where services asynchronously invoke other services.

A failure can occur in either of the following situations:

  • If a service is unable to respond to requests in a timely manner because of latency issues and unusually high traffic volumes
  • If a service is temporarily unavailable because of network connection issues

In these situations, other services might exhaust critical resources by attempting to contact a service that is too slow or unable to respond. These other services can then become unusable, which causes a cascading failure that affects the entire microservice architecture. By using the circuit breaker add-on in your Node.js application code, you can make your applications more fault tolerant and resilient.

1.2. Circuit breaker design pattern

The circuit breaker pattern is designed to handle failures in service architectures and to prevent cascading failures across multiple systems. A circuit breaker can act as a proxy for a client function that is sending requests to a remote service endpoint that might fail. You can wrap any requests sent to the remote service endpoint in a circuit breaker object. The circuit breaker then calls the remote service and monitors its status. If the number of failures reaches a specified percentage threshold, the circuit breaker is triggered. The circuit breaker then ensures that any further requests to the remote service are automatically blocked with an error message or fallback response for a specified time period.

Based on the circuit breaker design pattern, the circuit breaker has one of the following states at any specific time:

Closed
The number of failures is below the specified percentage threshold that can trigger the circuit breaker. You can define the percentage threshold as an optional parameter that is passed to the circuit breaker in your Node.js application. The default percentage threshold is 50%. When the number of failures is low and the circuit breaker is closed, the client function can continue to send requests to the remote service endpoint.
Open
The number of failures has reached the specified percentage threshold that triggers the circuit breaker. For example, based on the default options, the circuit breaker moves to an open state if 50% of requests fail. The circuit breaker then blocks all calls to the remote service endpoint, with an error message or fallback response, for a specified timeout period. You can define the timeout period as an optional parameter that is passed to the circuit breaker in your Node.js application. The default timeout period is 30 seconds.
Half open
The specified timeout period has ended. For example, based on the default options, the timeout period ends and the circuit breaker moves to a half-open state after 30 seconds. The circuit breaker then attempts to send a limited number of test calls to the remote service endpoint. If the test calls succeed, the circuit breaker moves to a closed state, and the client function can continue to send requests to the remote service. However, if the test calls fail, the circuit breaker reverts to an open state, and it continues to block all calls to the remote service for the specified timeout period.
返回顶部
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。 了解我们当前的更新.

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

Theme

© 2025 Red Hat