使用 Spring Reactor 时为什么要使用断路器和隔板? [英] Why use Circuit Breaker and Bulkhead when working with Spring Reactor?

查看:43
本文介绍了使用 Spring Reactor 时为什么要使用断路器和隔板?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请帮我找出断路器和隔板模式在 Spring Reactor 应用程序中有用的原因.

Please help me find reasons why Circuit breaker and Bulkhead patterns are useful in a Spring Reactor application.

由于操作在 Reactor 中将是非阻塞的,并且这两种模式旨在节省对资源(主要是线程)的潜在影响,在什么情况下我可以使我的 Spring Reactor 应用程序中的模式受益.在这一点上,我唯一看到的是,如果请求数量如此之大,以至于将它们保存在内存中,同时等待超时(而不是断路器启动和回退),我们会运行 OOM.

Since operations will be non-blocking in Reactor and those two patterns aim at saving potential hit to resources (mostly threads), in what cases can I benefit the patterns in my Spring Reactor app. The only thing I see at this point is if the requests are such a tremendously huge amount that keeping them in memory, while waiting for a timeout (instead of Circuit Breaker being up and falling back) we run OOM.

推荐答案

除了保护您自己的应用程序之外,这些模式还可以帮助您保护外部服务(REST API、数据库等):在延迟和/或错误率增加的情况下,你给他们恢复的空间.在您的应用程序中快速失败也是有益的,因为您不会让您的最终用户等待太久的错误.

Beside protecting your own application, these patterns also help you protect external services (REST API, database, etc): in case of increased latency and/or error rate, you give them room to recover. Failing fast in your application is also beneficial as you don't make your end-users wait too long for an error.

Resilience4j 为这些模式提供了专用的Reactor 支持,代替了已弃用的 Hystrix 库.

Resilience4j provides dedicated Reactor support for these patterns in place of the deprecated Hystrix library.

这篇关于使用 Spring Reactor 时为什么要使用断路器和隔板?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆