Sentinel系統自適應限流

前言

系統自適應目的在於在保證系統穩定的同時儘可能提高吞吐量,是一種從整體維度綜合考慮的一種限流方法。包括:系統Load、CPU使用率、整體入口QPS、總的併發執行緒數、平均RT。

二、引數說明

Sentinel系統自適應限流

三、原始碼註解

Sentinel系統自適應限流

原始碼註解(一)

Sentinel系統自適應限流

原始碼註解(二)

Sentinel系統自適應限流

小結:系統自適應只針對入口流量;當全域性QPS設 > 設定的QPS閾值時,觸發系統自適應流控;

當全域性併發執行緒數 > 設定的執行緒併發閾值maxThread時,觸發系統自適應流控;

當全域性平均RT > 設定的平均RT閾值avgRt時,觸發系統自適應流控;

當系統Load > 設定的系統最高負載閾值highestSystemLoad時,進行如下判斷:當前全域性併發執行緒數 > 系統容量時,觸發觸發系統自適應流控;系統容量了= maxQps * minRt / 1000。

四、BBR演算法簡述

1.BBR演算法含義

BBR一種擁塞控制演算法,主動探測出站資料(頻寬)和往返時間(round-trip time,RTT),不斷調整發送速率的一種演算法。

For a given network connection, BBR uses recent measurements of the network‘s delivery rate and round-trip time to build an explicit model that includes both the maximum recent bandwidth available to that connection, and its minimum recent round-trip delay。 BBR then uses this model to control both how fast it sends data and the maximum amount of data it’s willing to allow in the network at any time。

基於丟包擁塞演算法與BBR擁塞演算法效能圖示

Sentinel系統自適應限流

2.BDP頻寬延時積

BDP(Bandwidth-Delay Product),頻寬延時積也就是頻寬和延遲的乘積。

公式:BDP = min(RTT) * max(bandwidth),表示允許透過的最大流量。

應用到Sentinel系統自適應限流中:

公式:系統容量(BDP)= maxQps * minRt

Sentinel系統自適應限流

小結:圖示中紅色區域面積即Sentinle中的系統容量,長度為最小RT,寬頻為最大Qps,當前流量超過系統容量時觸發自適應限流。

五、規則示例

格式一

Sentinel系統自適應限流

格式二

Sentinel系統自適應限流

六、後記

歡迎關注*微**信**公**眾**號

「瓜農老梁」

,我在這裡等你。