<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ## 系統保護規則 (SystemRule) Sentinel 系統自適應限流從整體維度對應用入口流量進行控制,結合應用的 Load、總體平均 RT、入口 QPS 和線程數等幾個維度的監控指標,讓系統的入口流量和系統的負載達到一個平衡,讓系統盡可能跑在最大吞吐量的同時保證系統整體的穩定性。 ![](https://img.kancloud.cn/fb/56/fb56e4c24f0602583b861d5b1f737c60_1833x508.png) 系統保護規則是從應用級別的入口流量進行控制,從單臺機器的總體 Load、RT、入口 QPS 和線程數四個維度監控應用數據,讓系統盡可能跑在最大吞吐量的同時保證系統整體的穩定性。 系統保護規則是應用整體維度的,而不是資源維度的,并且**僅對入口流量生效**。入口流量指的是進入應用的流量(`EntryType.IN`),比如 Web 服務或 Dubbo 服務端接收的請求,都屬于入口流量。 系統規則支持以下的閾值類型: \-?**Load**(僅對 Linux/Unix-like 機器生效):當系統 load1 超過閾值,且系統當前的并發線程數超過系統容量時才會觸發系統保護。系統容量由系統的?`maxQps * minRt`?計算得出。設定參考值一般是?`CPU cores * 2.5`。 \-?**CPU usage**(1.5.0+ 版本):當系統 CPU 使用率超過閾值即觸發系統保護(取值范圍 0.0-1.0)。 \-?**RT**:當單臺機器上所有入口流量的平均 RT 達到閾值即觸發系統保護,單位是毫秒。 \-?**線程數**:當單臺機器上所有入口流量的并發線程數達到閾值即觸發系統保護。 \-?**入口 QPS**:當單臺機器上所有入口流量的 QPS 達到閾值即觸發系統保護。 核心代碼 ```java com.alibaba.csp.sentinel.slots.system.SystemRuleManager ``` ```java ????private static boolean checkBbr(int currentThread) { ????????if (currentThread > 1 && ????????????currentThread > Constants.ENTRY_NODE.maxSuccessQps() * Constants.ENTRY_NODE.minRt() / 1000) { ????????????return false; ????????} ????????return true; ????} ``` ```java ?public static void checkSystem(ResourceWrapper resourceWrapper) throws BlockException { ????????// Ensure the checking switch is on. ????????if (!checkSystemStatus.get()) { ????????????return; ????????} ????????// for inbound traffic only ????????if (resourceWrapper.getEntryType() != EntryType.IN) { ????????????return; ????????} ????????// total qps ????????double currentQps = Constants.ENTRY_NODE == null ? 0.0 : Constants.ENTRY_NODE.successQps(); ????????if (currentQps > qps) { ????????????throw new SystemBlockException(resourceWrapper.getName(), "qps"); ????????} ????????// total thread ????????int currentThread = Constants.ENTRY_NODE == null ? 0 : Constants.ENTRY_NODE.curThreadNum(); ????????if (currentThread > maxThread) { ????????????throw new SystemBlockException(resourceWrapper.getName(), "thread"); ????????} ????????double rt = Constants.ENTRY_NODE == null ? 0 : Constants.ENTRY_NODE.avgRt(); ????????if (rt > maxRt) { ????????????throw new SystemBlockException(resourceWrapper.getName(), "rt"); ????????} ????????// load. BBR algorithm. ????????if (highestSystemLoadIsSet && getCurrentSystemAvgLoad() > highestSystemLoad) { ????????????if (!checkBbr(currentThread)) { ????????????????throw new SystemBlockException(resourceWrapper.getName(), "load"); ????????????} ????????} ????????// cpu usage ????????if (highestCpuUsageIsSet && getCurrentCpuUsage() > highestCpuUsage) { ????????????if (!checkBbr(currentThread)) { ????????????????throw new SystemBlockException(resourceWrapper.getName(), "cpu"); ????????????} ????????} ????} ``` ## 系統規則案例 ![](https://img.kancloud.cn/87/ab/87ab23376117fcc8e89e73fa37f212f3_803x726.png)
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看