Resilience4j断路器环位缓冲区大小配置(Resilience4j circuit

编程入门 行业动态 更新时间:2024-10-25 23:31:36
Resilience4j断路器环位缓冲区大小配置(Resilience4j circuit-breaker ring bit buffer size configuration)

我正在寻求实施到web应用程序的电路中断库的resilience4j 。

我的应用程序与两个服务对话,每个服务根据一天的时间接收每秒20到150个请求。 Resilience4j为您提供了为每个断路器定义一个配置的功能,使您可以配置阈值和环形缓冲区大小。

环缓冲区大小和韧性4j vs netflix hystrix实现的额外信息:

Hystrix默认将执行结果存储在10个1秒的窗口桶中。 如果通过1秒钟的窗口桶,则会创建一个新桶并丢弃最早的桶。 该库将执行结果存储在没有统计滚动时间窗口的Ring Bit Buffer中。 成功的呼叫存储为0位,失败的呼叫存储为1位。 Ring Bit Buffer具有可配置的固定大小,并将这些位存储在long []数组中,与布尔数组相比,该数组可以节省内存。 这意味着Ring Bit Buffer只需要一个16位长(64位)值的数组来存储1024个调用的状态。 优点是CircuitBreaker可以为低频和高频后端系统开箱即用,因为在时间窗口通过时执行结果不会丢失。

我的问题是 ,如果请求在每秒20到150之间波动,我如何确定环形缓冲区的最佳大小? 如果有人问我同样的问题,我会如何证明我选择的号码?

如果我将环形缓冲区设置为100,则每秒需要5秒才能填充@ 20个请求,而在高峰时间,填充时间不到1秒。 我不确定是否应该使用像hystrix这样的基于时间的实现,或者我是否可以使用resilience4j来解决此问题。

I'm looking to implement resilience4j circuit breaking library into a web application.

My application talks to two services and each service receives anywhere between 20 and 150 requests per second depending on the time of day. Resilience4j provides you with the ability to define a config for each circuit breaker which lets you configure the thresholds and ring buffer size.

Extra info on ring buffer size and resilience4j vs netflix hystrix implementation:

Hystrix, by default, stores execution results in 10 1-second window buckets. If a 1-second window bucket is passed, a new bucket is created and the oldest is dropped. This library stores execution results in Ring Bit Buffer without a statistical rolling time window. A successful call is stored as a 0 bit and a failed call is stored as a 1 bit. The Ring Bit Buffer has a configurable fixed-size and stores the bits in a long[] array which is saving memory compared to a boolean array. That means the Ring Bit Buffer only needs an array of 16 long (64-bit) values to store the status of 1024 calls. The advantage is that this CircuitBreaker works out-of-the-box for low and high frequency backend systems, because execution results are not dropped when a time window is passed.

My question is, with requests fluctuating between 20 and 150 per second, how do I determine the optimal size for the ring buffer? How would I justify the number I've chosen if someone asked me this same question?

If I set the ring buffer to 100, it will take 5 seconds to fill up @ 20 requests a second, and during peak hours it will take less than 1 second to fill up. I'm not sure if I should be using a time based implementation like hystrix or if I can work around this with resilience4j.

最满意答案

完全同意Jim Garrison的观点。

这种配置很大程度上取决于您的应用程序需求和行为。 在你能回答你的主要问题之前

如果请求在每秒钟20到150之间波动,我如何确定环形缓冲区的最佳大小?

你应该决定这个特定请求的典型错误率是多少,你的系统将如常处理,电路将保持关闭状态?

您还应该考虑系统对异常高错误率的反应速度。

通过接驳CircuitBraker配置,您将实际上在灵敏度和特异性之间取得平衡,这种平衡完全取决于您的业务需求。 例如,如果您的系统的安全性和可用性是您的首要任务,那么您可以接受一定数量的假正电路开路。

在真正的生产系统中,从头开始配置CircuitBreaker非常困难,所以准备好外部化此配置并在需要时进行更改。

Completely agree with Jim Garrison on that one.

This configuration will heavily depend on your applications requirements and behaviors. Before you can get answer to your primary question

With requests fluctuating between 20 and 150 per second, how do I determine the optimal size for the ring buffer?

you should decide what is the typical error rate for this particular requests that your system will treat like normal and circuit will stay closed?

Also you should take into account how fast your system should react to anomaly high error rates.

By adjasting CircuitBraker configuration you will actually balance between sensitivity and specificity and this balance completely depends from your business requirements. For example if you have system where safety and availability are top priorities you can accept some amount of false positive circuit openings.

In real production systems it is pretty hard to configure CircuitBreaker from scratch, so be ready to externalize this config and change it when needed.

更多推荐

本文发布于:2023-08-02 20:54:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1381525.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:缓冲区   断路器   大小   Resilience4j   circuit

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!