sentinel之三種熔斷降級狀況的驗證

熔斷降級是指當資源處於不穩定的狀況下,在接下來的時間窗口以內,對該資源的調用都自動熔斷(默認行爲是拋出DegradeException)。
一般用三種方式來衡量資源是否處於穩定的狀態:java

平均響應時間 (DEGRADE_GRADE_RT):當資源的平均響應時間超過閾值(DegradeRule 中的 count,以 ms 爲單位)以後,資源進入準降級狀態。接下來若是持續進入 5 個請求,它們的 RT 都持續超過這個閾值,那麼在接下的時間窗口(DegradeRule 中的 timeWindow,以 s 爲單位)以內,對這個方法的調用都會自動地返回(拋出 DegradeException)。ide

異常比例 (DEGRADE_GRADE_EXCEPTION_RATIO):當資源的每秒異常總數佔經過量的比值超過閾值(DegradeRule 中的 count)以後,資源進入降級狀態,即在接下的時間窗口(DegradeRule 中的 timeWindow,以 s 爲單位)以內,對這個方法的調用都會自動地返回。異常比率的閾值範圍是 [0.0, 1.0],表明 0% - 100%。atom

異常數 (DEGRADE_GRADE_EXCEPTION_COUNT):當資源近 1 分鐘的異常數目超過閾值以後會進行熔斷。.net

注意:爲了統計異常比例或異常數,須要經過 Tracer.trace(ex) 記錄業務異常。
下面對這三種狀況作簡單的驗證code

導入Maven依賴
<dependency>
    <groupId>com.alibaba.csp</groupId>
    <artifactId>sentinel-core</artifactId>
    <version>1.3.0-GA</version>
</dependency>
1
2
3
4
5
點擊這裏可查詢最新的sentinel-core版本
一、驗證平均響應時間orm

import com.alibaba.csp.sentinel.Entry;
import com.alibaba.csp.sentinel.SphU;
import com.alibaba.csp.sentinel.slots.block.RuleConstant;
import com.alibaba.csp.sentinel.slots.block.degrade.DegradeRule;
import com.alibaba.csp.sentinel.slots.block.degrade.DegradeRuleManager;
import com.alibaba.csp.sentinel.util.TimeUtil;對象

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;blog

/**
 * 降級是在資源處於不穩定狀態時使用的,這些資源將在下一個定義的時間窗口內降級。
 * 有三種方法衡量資源是否穩定:
 * 平均響應時間 (DEGRADE_GRADE_RT):當資源的平均響應時間超過閾值(DegradeRule 中的 count,以 ms 爲單位)以後,
 * 資源進入準降級狀態。接下來若是持續進入 5 個請求,它們的 RT 都持續超過這個閾值,
 * 那麼在接下的時間窗口(DegradeRule 中的 timeWindow,以 s 爲單位)以內,
 * 對這個方法的調用都會自動地返回(拋出 DegradeException)
 * **異常比率,見 {@link ExceptionRatioDegradeDemo}.
 * **異常統計,見 {@link ExceptionCountDegradeDemo}.
 */
public class RtDegradeDemo {資源

    private static final String KEY = "平均響應時間";rem

    private static AtomicInteger pass = new AtomicInteger();
    private static AtomicInteger block = new AtomicInteger();
    private static AtomicInteger total = new AtomicInteger();

    private static volatile boolean stop = false;
    private static final int threadCount = 100;
    private static int seconds = 60;

    public static void main(String[] args) throws Exception {
        tick();
        initDegradeRule();// 設置資源降級規則

        for (int i = 0; i < threadCount; i++) {
            Thread entryThread = new Thread(new Runnable() {
                int j = 0;

                @Override
                public void run() {
                    while (true) {
                        Entry entry = null;
                        try {
                            TimeUnit.MILLISECONDS.sleep(5);
                            entry = SphU.entry(KEY);
                            // 令牌已得到
                            pass.incrementAndGet();// 先+1,而後在返回值,至關於++i
                            // sleep 600 ms, as rt
                            TimeUnit.MILLISECONDS.sleep(600);
                        } catch (Exception e) {
                            // System.out.println("異常:"+e);
                            // 降級計數
                            block.incrementAndGet();// 先+1,而後在返回值,至關於++i
                        } finally {
                            // 記錄總數
                            total.incrementAndGet();// 先+1,而後在返回值,至關於++i
                            if (entry != null) {
                                entry.exit();
                            }
                        }
                    }
                }

            });
            entryThread.setName("working-thread");
            entryThread.start();
        }
    }

    /**
     * 當資源的平均響應時間超過閾值(DegradeRule 中的 count,以 ms 爲單位)以後,資源進入準降級狀態。
     * 接下來若是持續進入 5 個請求,它們的 RT 都持續超過這個閾值,
     * 那麼在接下的時間窗口(DegradeRule 中的 timeWindow,以 s 爲單位)以內,
     * 對這個方法的調用都會自動地返回(拋出 DegradeException)。
     */
    private static void initDegradeRule() {
        List<DegradeRule> rules = new ArrayList<DegradeRule>();
        DegradeRule rule = new DegradeRule();
        rule.setResource(KEY);// 設置資源名,資源名是限流規則的做用對象
        rule.setCount(10);// 設置平均響應時間閾值爲10ms
        rule.setGrade(RuleConstant.DEGRADE_GRADE_RT);// 設置降級模式,根據平均響應時間降級
        rule.setTimeWindow(10);// 設置降級的時間,以s爲單位
        rules.add(rule);
        DegradeRuleManager.loadRules(rules);
    }

    private static void tick() {
        Thread timer = new Thread(new TimerTask());
        timer.setName("sentinel-timer-task");
        timer.start();
    }

    static class TimerTask implements Runnable {
        @Override
        public void run() {
            long start = System.currentTimeMillis();
            System.out.println("統計開始......");
            long oldTotal = 0;
            long oldPass = 0;
            long oldBlock = 0;

            SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            String nowTime = "";

            while (!stop) {
                try {
                    TimeUnit.SECONDS.sleep(1);
                } catch (InterruptedException e) {
                }

                long globalTotal = total.get();
                long oneSecondTotal = globalTotal - oldTotal;
                oldTotal = globalTotal;

                long globalPass = pass.get();
                long oneSecondPass = globalPass - oldPass;
                oldPass = globalPass;

                long globalBlock = block.get();
                long oneSecondBlock = globalBlock - oldBlock;
                oldBlock = globalBlock;

                nowTime = formatter.format(new java.util.Date(TimeUtil.currentTimeMillis()));
                System.out.println(nowTime + ", total:" + oneSecondTotal + ", pass:" + oneSecondPass + ", block:" + oneSecondBlock);

                if (seconds-- <= 0) {
                    stop = true;
                }
            }

            long cost = System.currentTimeMillis() - start;
            System.out.println("耗時:" + cost + " ms");
            System.out.println("總計數:" + total.get() + ", 經過數:" + pass.get() + ", 降級數:" + block.get());
            System.out.println("統計結束!");
            System.exit(0);
        }
    }

}

執行結果以下:

統計開始......
2018-12-10 16:42:26, total:2387, pass:104, block:2288
2018-12-10 16:42:27, total:15446, pass:0, block:15442
2018-12-10 16:42:28, total:17507, pass:0, block:17506
2018-12-10 16:42:29, total:17939, pass:0, block:17940
2018-12-10 16:42:30, total:17731, pass:0, block:17730
2018-12-10 16:42:31, total:17800, pass:0, block:17800
2018-12-10 16:42:32, total:17973, pass:0, block:17975
2018-12-10 16:42:33, total:17814, pass:0, block:17812
2018-12-10 16:42:34, total:18000, pass:0, block:18000
2018-12-10 16:42:35, total:17832, pass:0, block:17832
2018-12-10 16:42:36, total:14944, pass:100, block:14944
2018-12-10 16:42:37, total:9700, pass:4, block:9600
2018-12-10 16:42:38, total:18063, pass:0, block:18059
2018-12-10 16:42:39, total:17828, pass:0, block:17828
2018-12-10 16:42:40, total:18000, pass:0, block:18000
2018-12-10 16:42:41, total:17800, pass:0, block:17800
2018-12-10 16:42:42, total:17900, pass:0, block:17900
2018-12-10 16:42:43, total:17800, pass:0, block:17800
2018-12-10 16:42:44, total:17890, pass:0, block:17890
2018-12-10 16:42:45, total:17908, pass:0, block:17908
2018-12-10 16:42:46, total:17868, pass:0, block:17871
2018-12-10 16:42:47, total:7830, pass:100, block:7827
2018-12-10 16:42:48, total:16856, pass:4, block:16752
2018-12-10 16:42:49, total:17963, pass:0, block:17965
2018-12-10 16:42:50, total:17541, pass:0, block:17539
2018-12-10 16:42:51, total:17600, pass:0, block:17600
2018-12-10 16:42:52, total:17770, pass:0, block:17770
2018-12-10 16:42:53, total:17400, pass:0, block:17400
2018-12-10 16:42:54, total:17753, pass:0, block:17755
2018-12-10 16:42:55, total:17642, pass:0, block:17640
2018-12-10 16:42:56, total:17796, pass:0, block:17796
2018-12-10 16:42:57, total:17884, pass:0, block:17887
2018-12-10 16:42:58, total:6872, pass:104, block:6769
2018-12-10 16:42:59, total:17720, pass:0, block:17716
2018-12-10 16:43:00, total:17889, pass:0, block:17892
2018-12-10 16:43:01, total:17611, pass:0, block:17608
2018-12-10 16:43:02, total:17851, pass:0, block:17851
2018-12-10 16:43:03, total:17900, pass:0, block:17900
2018-12-10 16:43:04, total:17800, pass:0, block:17800
2018-12-10 16:43:05, total:17800, pass:0, block:17800
2018-12-10 16:43:06, total:17900, pass:0, block:17900
2018-12-10 16:43:07, total:17800, pass:0, block:17800
2018-12-10 16:43:08, total:11600, pass:100, block:11600
2018-12-10 16:43:09, total:12876, pass:4, block:12772
2018-12-10 16:43:10, total:17896, pass:0, block:17896
2018-12-10 16:43:11, total:17981, pass:0, block:17983
2018-12-10 16:43:12, total:17819, pass:0, block:17817
2018-12-10 16:43:13, total:17800, pass:0, block:17800
2018-12-10 16:43:14, total:17976, pass:0, block:17977
2018-12-10 16:43:15, total:17707, pass:0, block:17708
2018-12-10 16:43:16, total:17881, pass:0, block:17883
2018-12-10 16:43:17, total:17832, pass:0, block:17828
2018-12-10 16:43:18, total:17900, pass:0, block:17900
2018-12-10 16:43:19, total:6974, pass:104, block:6892
2018-12-10 16:43:20, total:17497, pass:0, block:17476
2018-12-10 16:43:21, total:17666, pass:0, block:17665
2018-12-10 16:43:22, total:18000, pass:0, block:18000
2018-12-10 16:43:23, total:17900, pass:0, block:17900
2018-12-10 16:43:24, total:17800, pass:0, block:17800
2018-12-10 16:43:25, total:17894, pass:0, block:17894
2018-12-10 16:43:26, total:17765, pass:0, block:17765
耗時:61080 ms
總計數:1014072, 經過數:624, 降級數:1013448
統計結束!

Process finished with exit code 0


二、驗證異常比例

import com.alibaba.csp.sentinel.Entry;
import com.alibaba.csp.sentinel.SphU;
import com.alibaba.csp.sentinel.Tracer;
import com.alibaba.csp.sentinel.slots.block.BlockException;
import com.alibaba.csp.sentinel.slots.block.RuleConstant;
import com.alibaba.csp.sentinel.slots.block.degrade.DegradeRule;
import com.alibaba.csp.sentinel.slots.block.degrade.DegradeRuleManager;
import com.alibaba.csp.sentinel.util.TimeUtil;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;

/**
 * 降級是在資源處於不穩定狀態時使用的,這些資源將在下一個定義的時間窗口內降級。
 * 有三種方法衡量資源是否穩定:
 * 異常比率:當異常計數/秒與成功的比率qps大於或等於閾值時,對資源的訪問將被阻塞在即將到來的時間窗口。
 * **異常統計,見 {@link ExceptionCountDegradeDemo}.
 * **平均響應時間, 見 {@link RtDegradeDemo}.
 */
public class ExceptionRatioDegradeDemo {
    private static final String KEY = "異常比率";

    private static AtomicInteger total = new AtomicInteger();
    private static AtomicInteger pass = new AtomicInteger();
    private static AtomicInteger block = new AtomicInteger();
    private static AtomicInteger bizException = new AtomicInteger();

    private static volatile boolean stop = false;
    private static final int threadCount = 1;
    private static int seconds = 60 + 40;

    public static void main(String[] args) throws Exception {
        tick();
        initDegradeRule();// 設置資源降級規則

        for (int i = 0; i < threadCount; i++) {
            Thread entryThread = new Thread(new Runnable() {
                @Override
                public void run() {
                    int count = 0;
                    while (true) {
                        count++;
                        Entry entry = null;
                        try {
                            Thread.sleep(20);
                            entry = SphU.entry(KEY);
                            // 得到令牌表示經過
                            pass.addAndGet(1);// 先+n,而後在返回值
                            if (count % 2 == 0) {
                                // 業務代碼引起異常
                                throw new RuntimeException("throw runtime exception");
                            }
                        } catch (BlockException e) {
                            // 降級計數
                            block.addAndGet(1);// 先+n,而後在返回值
                        } catch (Throwable t) {
                            // 記錄業務異常
                            bizException.incrementAndGet();// 先+1,而後在返回值,至關於++i
                            // 爲了統計異常比例或異常數,須要經過 Tracer.trace(ex) 記錄業務異常。
                            Tracer.trace(t);
                        } finally {
                            // 記錄總數
                            total.addAndGet(1);// 先+n,而後在返回值
                            if (entry != null) {
                                entry.exit();
                            }
                        }
                    }
                }

            });
            entryThread.setName("working-thread");
            entryThread.start();
        }

    }

    /**
     * 當資源的每秒異常總數佔經過量的比值超過閾值(DegradeRule 中的 count)以後,
     * 資源進入降級狀態,即在接下的時間窗口(DegradeRule 中的 timeWindow,以 s 爲單位)以內,對這個方法的調用都會自動地返回。
     * 異常比率的閾值範圍是 [0.0, 1.0],表明 0% - 100%。
     */
    private static void initDegradeRule() {
        List<DegradeRule> rules = new ArrayList<DegradeRule>();
        DegradeRule rule = new DegradeRule();
        rule.setResource(KEY);// 設置資源名,資源名是限流規則的做用對象
        // 將限制異常比率設置爲0.1
        rule.setCount(0.5);// 異常比率的閾值範圍是 [0.0, 1.0],表明 0% - 100%。
        rule.setGrade(RuleConstant.DEGRADE_GRADE_EXCEPTION_RATIO);// 設置降級模式,根據異常比率降級
        rule.setTimeWindow(10);// 設置降級的時間,以s爲單位
        rules.add(rule);
        DegradeRuleManager.loadRules(rules);
    }

    private static void tick() {
        Thread timer = new Thread(new TimerTask());
        timer.setName("sentinel-timer-task");
        timer.start();
    }

    static class TimerTask implements Runnable {
        @Override
        public void run() {
            long start = System.currentTimeMillis();
            System.out.println("統計開始......");
            long oldTotal = 0;
            long oldPass = 0;
            long oldBlock = 0;
            long oldBizException = 0;

            SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            String nowTime = "";

            while (!stop) {
                try {
                    TimeUnit.SECONDS.sleep(1);
                } catch (InterruptedException e) {
                }
                long globalTotal = total.get();
                long oneSecondTotal = globalTotal - oldTotal;
                oldTotal = globalTotal;

                long globalPass = pass.get();
                long oneSecondPass = globalPass - oldPass;
                oldPass = globalPass;

                long globalBlock = block.get();
                long oneSecondBlock = globalBlock - oldBlock;
                oldBlock = globalBlock;

                long globalBizException = bizException.get();
                long oneSecondBizException = globalBizException - oldBizException;
                oldBizException = globalBizException;

                nowTime = formatter.format(new java.util.Date(TimeUtil.currentTimeMillis()));
                System.out.println(nowTime + ", oneSecondTotal:" + oneSecondTotal
                        + ", oneSecondPass:" + oneSecondPass
                        + ", oneSecondBlock:" + oneSecondBlock
                        + ", oneSecondBizException:" + oneSecondBizException);
                if (seconds-- <= 0) {
                    stop = true;
                }
            }
            long cost = System.currentTimeMillis() - start;
            System.out.println("耗時:" + cost + " ms");
            System.out.println("總計數:" + total.get() + ", 經過數:" + pass.get()
                    + ", 降級數:" + block.get() + ", 業務異常數:" + bizException.get());
            System.out.println("統計結束!");
            System.exit(0);
        }
    }
}

執行結果以下:

統計開始......
2018-12-10 17:02:04, oneSecondTotal:37, oneSecondPass:6, oneSecondBlock:31, oneSecondBizException:3
2018-12-10 17:02:05, oneSecondTotal:47, oneSecondPass:0, oneSecondBlock:47, oneSecondBizException:0
2018-12-10 17:02:06, oneSecondTotal:49, oneSecondPass:0, oneSecondBlock:49, oneSecondBizException:0
2018-12-10 17:02:07, oneSecondTotal:48, oneSecondPass:0, oneSecondBlock:48, oneSecondBizException:0
2018-12-10 17:02:08, oneSecondTotal:49, oneSecondPass:0, oneSecondBlock:49, oneSecondBizException:0
2018-12-10 17:02:09, oneSecondTotal:48, oneSecondPass:0, oneSecondBlock:48, oneSecondBizException:0
2018-12-10 17:02:10, oneSecondTotal:48, oneSecondPass:0, oneSecondBlock:48, oneSecondBizException:0
2018-12-10 17:02:11, oneSecondTotal:49, oneSecondPass:0, oneSecondBlock:49, oneSecondBizException:0
2018-12-10 17:02:12, oneSecondTotal:48, oneSecondPass:0, oneSecondBlock:48, oneSecondBizException:0
2018-12-10 17:02:13, oneSecondTotal:47, oneSecondPass:0, oneSecondBlock:47, oneSecondBizException:0
2018-12-10 17:02:14, oneSecondTotal:48, oneSecondPass:2, oneSecondBlock:46, oneSecondBizException:1
2018-12-10 17:02:15, oneSecondTotal:48, oneSecondPass:0, oneSecondBlock:48, oneSecondBizException:0
2018-12-10 17:02:16, oneSecondTotal:48, oneSecondPass:0, oneSecondBlock:48, oneSecondBizException:0
2018-12-10 17:02:17, oneSecondTotal:48, oneSecondPass:0, oneSecondBlock:48, oneSecondBizException:0
2018-12-10 17:02:18, oneSecondTotal:48, oneSecondPass:0, oneSecondBlock:48, oneSecondBizException:0
2018-12-10 17:02:19, oneSecondTotal:49, oneSecondPass:0, oneSecondBlock:49, oneSecondBizException:0
2018-12-10 17:02:20, oneSecondTotal:48, oneSecondPass:0, oneSecondBlock:48, oneSecondBizException:0
2018-12-10 17:02:21, oneSecondTotal:48, oneSecondPass:0, oneSecondBlock:48, oneSecondBizException:0
2018-12-10 17:02:22, oneSecondTotal:49, oneSecondPass:0, oneSecondBlock:49, oneSecondBizException:0
2018-12-10 17:02:23, oneSecondTotal:48, oneSecondPass:0, oneSecondBlock:48, oneSecondBizException:0
2018-12-10 17:02:24, oneSecondTotal:48, oneSecondPass:2, oneSecondBlock:46, oneSecondBizException:1
2018-12-10 17:02:25, oneSecondTotal:49, oneSecondPass:0, oneSecondBlock:49, oneSecondBizException:0
2018-12-10 17:02:26, oneSecondTotal:48, oneSecondPass:0, oneSecondBlock:48, oneSecondBizException:0
2018-12-10 17:02:27, oneSecondTotal:48, oneSecondPass:0, oneSecondBlock:48, oneSecondBizException:0
2018-12-10 17:02:28, oneSecondTotal:49, oneSecondPass:0, oneSecondBlock:49, oneSecondBizException:0
2018-12-10 17:02:29, oneSecondTotal:48, oneSecondPass:0, oneSecondBlock:48, oneSecondBizException:0
2018-12-10 17:02:30, oneSecondTotal:48, oneSecondPass:0, oneSecondBlock:48, oneSecondBizException:0
2018-12-10 17:02:31, oneSecondTotal:48, oneSecondPass:0, oneSecondBlock:48, oneSecondBizException:0
2018-12-10 17:02:32, oneSecondTotal:48, oneSecondPass:0, oneSecondBlock:48, oneSecondBizException:0
2018-12-10 17:02:33, oneSecondTotal:49, oneSecondPass:0, oneSecondBlock:49, oneSecondBizException:0
2018-12-10 17:02:34, oneSecondTotal:48, oneSecondPass:2, oneSecondBlock:46, oneSecondBizException:1
2018-12-10 17:02:35, oneSecondTotal:48, oneSecondPass:0, oneSecondBlock:48, oneSecondBizException:0
2018-12-10 17:02:36, oneSecondTotal:48, oneSecondPass:0, oneSecondBlock:48, oneSecondBizException:0
2018-12-10 17:02:37, oneSecondTotal:48, oneSecondPass:0, oneSecondBlock:48, oneSecondBizException:0
2018-12-10 17:02:38, oneSecondTotal:49, oneSecondPass:0, oneSecondBlock:49, oneSecondBizException:0
2018-12-10 17:02:39, oneSecondTotal:48, oneSecondPass:0, oneSecondBlock:48, oneSecondBizException:0
2018-12-10 17:02:40, oneSecondTotal:48, oneSecondPass:0, oneSecondBlock:48, oneSecondBizException:0
2018-12-10 17:02:41, oneSecondTotal:48, oneSecondPass:0, oneSecondBlock:48, oneSecondBizException:0
2018-12-10 17:02:42, oneSecondTotal:48, oneSecondPass:0, oneSecondBlock:48, oneSecondBizException:0
2018-12-10 17:02:43, oneSecondTotal:48, oneSecondPass:0, oneSecondBlock:48, oneSecondBizException:0
2018-12-10 17:02:44, oneSecondTotal:48, oneSecondPass:2, oneSecondBlock:46, oneSecondBizException:1
2018-12-10 17:02:45, oneSecondTotal:49, oneSecondPass:0, oneSecondBlock:49, oneSecondBizException:0
2018-12-10 17:02:46, oneSecondTotal:48, oneSecondPass:0, oneSecondBlock:48, oneSecondBizException:0
2018-12-10 17:02:47, oneSecondTotal:48, oneSecondPass:0, oneSecondBlock:48, oneSecondBizException:0
2018-12-10 17:02:48, oneSecondTotal:49, oneSecondPass:0, oneSecondBlock:49, oneSecondBizException:0
2018-12-10 17:02:49, oneSecondTotal:48, oneSecondPass:0, oneSecondBlock:48, oneSecondBizException:0
2018-12-10 17:02:50, oneSecondTotal:49, oneSecondPass:0, oneSecondBlock:49, oneSecondBizException:0
2018-12-10 17:02:51, oneSecondTotal:48, oneSecondPass:0, oneSecondBlock:48, oneSecondBizException:0
2018-12-10 17:02:52, oneSecondTotal:49, oneSecondPass:0, oneSecondBlock:49, oneSecondBizException:0
2018-12-10 17:02:53, oneSecondTotal:48, oneSecondPass:0, oneSecondBlock:48, oneSecondBizException:0
2018-12-10 17:02:54, oneSecondTotal:48, oneSecondPass:2, oneSecondBlock:46, oneSecondBizException:1
2018-12-10 17:02:55, oneSecondTotal:48, oneSecondPass:0, oneSecondBlock:48, oneSecondBizException:0
2018-12-10 17:02:56, oneSecondTotal:48, oneSecondPass:0, oneSecondBlock:48, oneSecondBizException:0
2018-12-10 17:02:57, oneSecondTotal:49, oneSecondPass:0, oneSecondBlock:49, oneSecondBizException:0
2018-12-10 17:02:58, oneSecondTotal:48, oneSecondPass:0, oneSecondBlock:48, oneSecondBizException:0
2018-12-10 17:02:59, oneSecondTotal:49, oneSecondPass:0, oneSecondBlock:49, oneSecondBizException:0
2018-12-10 17:03:00, oneSecondTotal:48, oneSecondPass:0, oneSecondBlock:48, oneSecondBizException:0
2018-12-10 17:03:01, oneSecondTotal:48, oneSecondPass:0, oneSecondBlock:48, oneSecondBizException:0
2018-12-10 17:03:02, oneSecondTotal:49, oneSecondPass:0, oneSecondBlock:49, oneSecondBizException:0
2018-12-10 17:03:03, oneSecondTotal:48, oneSecondPass:0, oneSecondBlock:48, oneSecondBizException:0
2018-12-10 17:03:04, oneSecondTotal:49, oneSecondPass:2, oneSecondBlock:47, oneSecondBizException:1
2018-12-10 17:03:05, oneSecondTotal:48, oneSecondPass:0, oneSecondBlock:48, oneSecondBizException:0
2018-12-10 17:03:06, oneSecondTotal:48, oneSecondPass:0, oneSecondBlock:48, oneSecondBizException:0
2018-12-10 17:03:07, oneSecondTotal:49, oneSecondPass:0, oneSecondBlock:49, oneSecondBizException:0
2018-12-10 17:03:08, oneSecondTotal:48, oneSecondPass:0, oneSecondBlock:48, oneSecondBizException:0
2018-12-10 17:03:09, oneSecondTotal:48, oneSecondPass:0, oneSecondBlock:48, oneSecondBizException:0
2018-12-10 17:03:10, oneSecondTotal:49, oneSecondPass:0, oneSecondBlock:49, oneSecondBizException:0
2018-12-10 17:03:11, oneSecondTotal:48, oneSecondPass:0, oneSecondBlock:48, oneSecondBizException:0
2018-12-10 17:03:12, oneSecondTotal:49, oneSecondPass:0, oneSecondBlock:49, oneSecondBizException:0
2018-12-10 17:03:13, oneSecondTotal:48, oneSecondPass:0, oneSecondBlock:48, oneSecondBizException:0
2018-12-10 17:03:14, oneSecondTotal:49, oneSecondPass:2, oneSecondBlock:47, oneSecondBizException:1
2018-12-10 17:03:15, oneSecondTotal:48, oneSecondPass:0, oneSecondBlock:48, oneSecondBizException:0
2018-12-10 17:03:16, oneSecondTotal:49, oneSecondPass:0, oneSecondBlock:49, oneSecondBizException:0
2018-12-10 17:03:17, oneSecondTotal:48, oneSecondPass:0, oneSecondBlock:48, oneSecondBizException:0
2018-12-10 17:03:18, oneSecondTotal:48, oneSecondPass:0, oneSecondBlock:48, oneSecondBizException:0
2018-12-10 17:03:19, oneSecondTotal:49, oneSecondPass:0, oneSecondBlock:49, oneSecondBizException:0
2018-12-10 17:03:20, oneSecondTotal:48, oneSecondPass:0, oneSecondBlock:48, oneSecondBizException:0
2018-12-10 17:03:21, oneSecondTotal:49, oneSecondPass:0, oneSecondBlock:49, oneSecondBizException:0
2018-12-10 17:03:22, oneSecondTotal:48, oneSecondPass:0, oneSecondBlock:48, oneSecondBizException:0
2018-12-10 17:03:23, oneSecondTotal:49, oneSecondPass:0, oneSecondBlock:49, oneSecondBizException:0
2018-12-10 17:03:24, oneSecondTotal:48, oneSecondPass:2, oneSecondBlock:46, oneSecondBizException:1
2018-12-10 17:03:25, oneSecondTotal:49, oneSecondPass:0, oneSecondBlock:49, oneSecondBizException:0
2018-12-10 17:03:26, oneSecondTotal:48, oneSecondPass:0, oneSecondBlock:48, oneSecondBizException:0
2018-12-10 17:03:27, oneSecondTotal:48, oneSecondPass:0, oneSecondBlock:48, oneSecondBizException:0
2018-12-10 17:03:28, oneSecondTotal:49, oneSecondPass:0, oneSecondBlock:49, oneSecondBizException:0
2018-12-10 17:03:29, oneSecondTotal:48, oneSecondPass:0, oneSecondBlock:48, oneSecondBizException:0
2018-12-10 17:03:30, oneSecondTotal:48, oneSecondPass:0, oneSecondBlock:48, oneSecondBizException:0
2018-12-10 17:03:31, oneSecondTotal:49, oneSecondPass:0, oneSecondBlock:49, oneSecondBizException:0
2018-12-10 17:03:32, oneSecondTotal:48, oneSecondPass:0, oneSecondBlock:48, oneSecondBizException:0
2018-12-10 17:03:33, oneSecondTotal:49, oneSecondPass:0, oneSecondBlock:49, oneSecondBizException:0
2018-12-10 17:03:34, oneSecondTotal:48, oneSecondPass:2, oneSecondBlock:46, oneSecondBizException:1
2018-12-10 17:03:35, oneSecondTotal:48, oneSecondPass:0, oneSecondBlock:48, oneSecondBizException:0
2018-12-10 17:03:36, oneSecondTotal:49, oneSecondPass:0, oneSecondBlock:49, oneSecondBizException:0
2018-12-10 17:03:37, oneSecondTotal:48, oneSecondPass:0, oneSecondBlock:48, oneSecondBizException:0
2018-12-10 17:03:38, oneSecondTotal:48, oneSecondPass:0, oneSecondBlock:48, oneSecondBizException:0
2018-12-10 17:03:39, oneSecondTotal:48, oneSecondPass:0, oneSecondBlock:48, oneSecondBizException:0
2018-12-10 17:03:40, oneSecondTotal:48, oneSecondPass:0, oneSecondBlock:48, oneSecondBizException:0
2018-12-10 17:03:41, oneSecondTotal:48, oneSecondPass:0, oneSecondBlock:48, oneSecondBizException:0
2018-12-10 17:03:42, oneSecondTotal:48, oneSecondPass:0, oneSecondBlock:48, oneSecondBizException:0
2018-12-10 17:03:43, oneSecondTotal:48, oneSecondPass:0, oneSecondBlock:48, oneSecondBizException:0
2018-12-10 17:03:44, oneSecondTotal:48, oneSecondPass:2, oneSecondBlock:46, oneSecondBizException:1
耗時:101096 ms
總計數:4865, 經過數:26, 降級數:4839, 業務異常數:13
統計結束!

Process finished with exit code 0

三、驗證異常數

import com.alibaba.csp.sentinel.Entry;
import com.alibaba.csp.sentinel.SphU;
import com.alibaba.csp.sentinel.Tracer;
import com.alibaba.csp.sentinel.slots.block.BlockException;
import com.alibaba.csp.sentinel.slots.block.RuleConstant;
import com.alibaba.csp.sentinel.slots.block.degrade.DegradeRule;
import com.alibaba.csp.sentinel.slots.block.degrade.DegradeRuleManager;
import com.alibaba.csp.sentinel.util.TimeUtil;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;

/**
 * 降級是在資源處於不穩定狀態時使用的,這些資源將在下一個定義的時間窗口內降級。
 * 有三種方法衡量資源是否穩定:
 * 異常計數:當異常計數在最後60秒內大於或等於閾值時,對資源的訪問將被阻塞在時間窗口。
 * **異常比率,見{@link ExceptionRatioDegradeDemo}。
 * **平均響應時間,見{@link RtDegradeDemo}。
 * 注意:當經過{@link RuleConstant#DEGRADE_GRADE_EXCEPTION_COUNT}進行降級時,時間窗口少於60秒將沒法正常工做。
 * 由於異常計數是按分鐘求和的,因此在較短的時間窗口事後,仍然能夠知足降級條件。
 */
public class ExceptionCountDegradeDemo {
    private static final String KEY = "異常計數";

    private static AtomicInteger total = new AtomicInteger();
    private static AtomicInteger pass = new AtomicInteger();
    private static AtomicInteger block = new AtomicInteger();
    private static AtomicInteger bizException = new AtomicInteger();

    private static volatile boolean stop = false;
    private static final int threadCount = 1;
    private static int seconds = 60 + 40;

    public static void main(String[] args) throws Exception {
        tick();
        initDegradeRule();// 設置資源降級規則

        for (int i = 0; i < threadCount; i++) {
            Thread entryThread = new Thread(new Runnable() {
                @Override
                public void run() {
                    int count = 0;
                    while (true) {
                        count++;
                        Entry entry = null;
                        try {
                            Thread.sleep(20);
                            entry = SphU.entry(KEY);
                            // 得到令牌表示經過
                            pass.addAndGet(1);// 先+n,而後在返回值
                            if (count % 2 == 0) {
                                // 業務代碼引起異常
                                throw new RuntimeException("throw runtime exception");
                            }
                        } catch (BlockException e) {
                            // 降級計數
                            block.addAndGet(1);// 先+n,而後在返回值
                        } catch (Throwable t) {
                            // 記錄業務異常
                            bizException.incrementAndGet();// 先+1,而後在返回值,至關於++i
                            // 爲了統計異常比例或異常數,須要經過 Tracer.trace(ex) 記錄業務異常。
                            Tracer.trace(t);
                        } finally {
                            // 記錄總數
                            total.addAndGet(1);// 先+n,而後在返回值
                            if (entry != null) {
                                entry.exit();
                            }
                        }
                    }
                }

            });
            entryThread.setName("working-thread");
            entryThread.start();
        }

    }

    /**
     * 當資源近 1 分鐘的異常數目超過閾值以後會進行熔斷
     */
    private static void initDegradeRule() {
        List<DegradeRule> rules = new ArrayList<DegradeRule>();
        DegradeRule rule = new DegradeRule();
        rule.setResource(KEY);// 設置資源名,資源名是限流規則的做用對象
        rule.setCount(800);// 設置限流閾值,將異常計數限制爲800
        rule.setGrade(RuleConstant.DEGRADE_GRADE_EXCEPTION_COUNT);// 設置降級模式,根據異常計數降級
        /*
         * 當經過{@link RuleConstant#DEGRADE_GRADE_EXCEPTION_COUNT},進行降級時,時間窗口少於60秒將沒法正常工做。
         * 由於異常計數是按分鐘求和的,因此在較短的時間窗口事後,仍然能夠知足降級條件。
         * 如在10秒內已經達到降級閾值,且加上setTimeWindow設置的降級時間仍未超過一分鐘的,
         * 則在一分鐘內仍然知足降級條件,setTimeWindow設置的降級時間不生效,需等待滿一分鐘時間後才能恢復服務。
         */
        rule.setTimeWindow(10);// 設置降級的時間,以s爲單位
        rules.add(rule);
        DegradeRuleManager.loadRules(rules);
    }

    private static void tick() {
        Thread timer = new Thread(new TimerTask());
        timer.setName("sentinel-timer-task");
        timer.start();
    }

    static class TimerTask implements Runnable {
        @Override
        public void run() {
            long start = System.currentTimeMillis();
            System.out.println("統計開始......");
            long oldTotal = 0;
            long oldPass = 0;
            long oldBlock = 0;
            long oldBizException = 0;

            SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            String nowTime = "";

            while (!stop) {
                try {
                    TimeUnit.SECONDS.sleep(1);
                } catch (InterruptedException e) {
                }
                long globalTotal = total.get();
                long oneSecondTotal = globalTotal - oldTotal;
                oldTotal = globalTotal;

                long globalPass = pass.get();
                long oneSecondPass = globalPass - oldPass;
                oldPass = globalPass;

                long globalBlock = block.get();
                long oneSecondBlock = globalBlock - oldBlock;
                oldBlock = globalBlock;

                long globalBizException = bizException.get();
                long oneSecondBizException = globalBizException - oldBizException;
                oldBizException = globalBizException;

                nowTime = formatter.format(new java.util.Date(TimeUtil.currentTimeMillis()));
                System.out.println(nowTime + ", oneSecondTotal:" + oneSecondTotal
                        + ", oneSecondPass:" + oneSecondPass
                        + ", oneSecondBlock:" + oneSecondBlock
                        + ", oneSecondBizException:" + oneSecondBizException);

                if (seconds-- <= 0) {
                    stop = true;
                }
            }
            long cost = System.currentTimeMillis() - start;
            System.out.println("耗時:" + cost + " ms");
            System.out.println("總計數:" + total.get() + ", 經過數:" + pass.get()
                    + ", 降級數:" + block.get() + ", 業務異常數:" + bizException.get());
            System.out.println("統計結束!");
            System.exit(0);
        }
    }
}


執行結果以下:

統計開始...... 2018-12-10 17:06:00, oneSecondTotal:37, oneSecondPass:37, oneSecondBlock:0, oneSecondBizException:18 2018-12-10 17:06:01, oneSecondTotal:47, oneSecondPass:47, oneSecondBlock:0, oneSecondBizException:24 2018-12-10 17:06:02, oneSecondTotal:48, oneSecondPass:48, oneSecondBlock:0, oneSecondBizException:24 2018-12-10 17:06:03, oneSecondTotal:48, oneSecondPass:48, oneSecondBlock:0, oneSecondBizException:24 2018-12-10 17:06:04, oneSecondTotal:48, oneSecondPass:48, oneSecondBlock:0, oneSecondBizException:24 2018-12-10 17:06:05, oneSecondTotal:48, oneSecondPass:48, oneSecondBlock:0, oneSecondBizException:24 2018-12-10 17:06:06, oneSecondTotal:48, oneSecondPass:48, oneSecondBlock:0, oneSecondBizException:24 2018-12-10 17:06:07, oneSecondTotal:49, oneSecondPass:49, oneSecondBlock:0, oneSecondBizException:24 2018-12-10 17:06:08, oneSecondTotal:48, oneSecondPass:48, oneSecondBlock:0, oneSecondBizException:24 2018-12-10 17:06:09, oneSecondTotal:48, oneSecondPass:48, oneSecondBlock:0, oneSecondBizException:24 2018-12-10 17:06:10, oneSecondTotal:49, oneSecondPass:49, oneSecondBlock:0, oneSecondBizException:25 2018-12-10 17:06:11, oneSecondTotal:48, oneSecondPass:48, oneSecondBlock:0, oneSecondBizException:24 2018-12-10 17:06:12, oneSecondTotal:48, oneSecondPass:48, oneSecondBlock:0, oneSecondBizException:24 2018-12-10 17:06:13, oneSecondTotal:48, oneSecondPass:48, oneSecondBlock:0, oneSecondBizException:24 2018-12-10 17:06:14, oneSecondTotal:49, oneSecondPass:49, oneSecondBlock:0, oneSecondBizException:24 2018-12-10 17:06:15, oneSecondTotal:48, oneSecondPass:48, oneSecondBlock:0, oneSecondBizException:24 2018-12-10 17:06:16, oneSecondTotal:48, oneSecondPass:48, oneSecondBlock:0, oneSecondBizException:24 2018-12-10 17:06:17, oneSecondTotal:48, oneSecondPass:48, oneSecondBlock:0, oneSecondBizException:24 2018-12-10 17:06:18, oneSecondTotal:48, oneSecondPass:48, oneSecondBlock:0, oneSecondBizException:24 2018-12-10 17:06:19, oneSecondTotal:49, oneSecondPass:49, oneSecondBlock:0, oneSecondBizException:25 2018-12-10 17:06:20, oneSecondTotal:48, oneSecondPass:48, oneSecondBlock:0, oneSecondBizException:24 2018-12-10 17:06:21, oneSecondTotal:48, oneSecondPass:48, oneSecondBlock:0, oneSecondBizException:24 2018-12-10 17:06:22, oneSecondTotal:48, oneSecondPass:48, oneSecondBlock:0, oneSecondBizException:24 2018-12-10 17:06:23, oneSecondTotal:49, oneSecondPass:49, oneSecondBlock:0, oneSecondBizException:24 2018-12-10 17:06:24, oneSecondTotal:48, oneSecondPass:48, oneSecondBlock:0, oneSecondBizException:24 2018-12-10 17:06:25, oneSecondTotal:49, oneSecondPass:49, oneSecondBlock:0, oneSecondBizException:25 2018-12-10 17:06:26, oneSecondTotal:48, oneSecondPass:48, oneSecondBlock:0, oneSecondBizException:24 2018-12-10 17:06:27, oneSecondTotal:48, oneSecondPass:48, oneSecondBlock:0, oneSecondBizException:24 2018-12-10 17:06:28, oneSecondTotal:48, oneSecondPass:48, oneSecondBlock:0, oneSecondBizException:24 2018-12-10 17:06:29, oneSecondTotal:48, oneSecondPass:48, oneSecondBlock:0, oneSecondBizException:24 2018-12-10 17:06:30, oneSecondTotal:48, oneSecondPass:48, oneSecondBlock:0, oneSecondBizException:24 2018-12-10 17:06:31, oneSecondTotal:49, oneSecondPass:49, oneSecondBlock:0, oneSecondBizException:24 2018-12-10 17:06:32, oneSecondTotal:47, oneSecondPass:47, oneSecondBlock:0, oneSecondBizException:24 2018-12-10 17:06:33, oneSecondTotal:47, oneSecondPass:22, oneSecondBlock:25, oneSecondBizException:11 2018-12-10 17:06:34, oneSecondTotal:49, oneSecondPass:0, oneSecondBlock:49, oneSecondBizException:0 2018-12-10 17:06:35, oneSecondTotal:48, oneSecondPass:0, oneSecondBlock:48, oneSecondBizException:0 2018-12-10 17:06:36, oneSecondTotal:49, oneSecondPass:0, oneSecondBlock:49, oneSecondBizException:0 2018-12-10 17:06:37, oneSecondTotal:48, oneSecondPass:0, oneSecondBlock:48, oneSecondBizException:0 2018-12-10 17:06:38, oneSecondTotal:48, oneSecondPass:0, oneSecondBlock:48, oneSecondBizException:0 2018-12-10 17:06:39, oneSecondTotal:48, oneSecondPass:0, oneSecondBlock:48, oneSecondBizException:0 2018-12-10 17:06:40, oneSecondTotal:49, oneSecondPass:0, oneSecondBlock:49, oneSecondBizException:0 2018-12-10 17:06:41, oneSecondTotal:49, oneSecondPass:0, oneSecondBlock:49, oneSecondBizException:0 2018-12-10 17:06:42, oneSecondTotal:48, oneSecondPass:0, oneSecondBlock:48, oneSecondBizException:0 2018-12-10 17:06:43, oneSecondTotal:48, oneSecondPass:0, oneSecondBlock:48, oneSecondBizException:0 2018-12-10 17:06:44, oneSecondTotal:49, oneSecondPass:0, oneSecondBlock:49, oneSecondBizException:0 2018-12-10 17:06:45, oneSecondTotal:48, oneSecondPass:0, oneSecondBlock:48, oneSecondBizException:0 2018-12-10 17:06:46, oneSecondTotal:48, oneSecondPass:0, oneSecondBlock:48, oneSecondBizException:0 2018-12-10 17:06:47, oneSecondTotal:49, oneSecondPass:0, oneSecondBlock:49, oneSecondBizException:0 2018-12-10 17:06:48, oneSecondTotal:48, oneSecondPass:0, oneSecondBlock:48, oneSecondBizException:0 2018-12-10 17:06:49, oneSecondTotal:49, oneSecondPass:0, oneSecondBlock:49, oneSecondBizException:0 2018-12-10 17:06:50, oneSecondTotal:48, oneSecondPass:0, oneSecondBlock:48, oneSecondBizException:0 2018-12-10 17:06:51, oneSecondTotal:48, oneSecondPass:0, oneSecondBlock:48, oneSecondBizException:0 2018-12-10 17:06:52, oneSecondTotal:49, oneSecondPass:0, oneSecondBlock:49, oneSecondBizException:0 2018-12-10 17:06:53, oneSecondTotal:48, oneSecondPass:0, oneSecondBlock:48, oneSecondBizException:0 2018-12-10 17:06:54, oneSecondTotal:49, oneSecondPass:0, oneSecondBlock:49, oneSecondBizException:0 2018-12-10 17:06:55, oneSecondTotal:48, oneSecondPass:0, oneSecondBlock:48, oneSecondBizException:0 2018-12-10 17:06:56, oneSecondTotal:49, oneSecondPass:0, oneSecondBlock:49, oneSecondBizException:0 2018-12-10 17:06:57, oneSecondTotal:48, oneSecondPass:0, oneSecondBlock:48, oneSecondBizException:0 2018-12-10 17:06:58, oneSecondTotal:48, oneSecondPass:0, oneSecondBlock:48, oneSecondBizException:0 2018-12-10 17:06:59, oneSecondTotal:48, oneSecondPass:0, oneSecondBlock:48, oneSecondBizException:0 2018-12-10 17:07:00, oneSecondTotal:48, oneSecondPass:0, oneSecondBlock:48, oneSecondBizException:0 2018-12-10 17:07:01, oneSecondTotal:49, oneSecondPass:0, oneSecondBlock:49, oneSecondBizException:0 2018-12-10 17:07:02, oneSecondTotal:48, oneSecondPass:0, oneSecondBlock:48, oneSecondBizException:0 2018-12-10 17:07:03, oneSecondTotal:47, oneSecondPass:25, oneSecondBlock:22, oneSecondBizException:12 2018-12-10 17:07:04, oneSecondTotal:48, oneSecondPass:48, oneSecondBlock:0, oneSecondBizException:24 2018-12-10 17:07:05, oneSecondTotal:48, oneSecondPass:48, oneSecondBlock:0, oneSecondBizException:24 2018-12-10 17:07:06, oneSecondTotal:48, oneSecondPass:48, oneSecondBlock:0, oneSecondBizException:24 2018-12-10 17:07:07, oneSecondTotal:48, oneSecondPass:48, oneSecondBlock:0, oneSecondBizException:24 2018-12-10 17:07:08, oneSecondTotal:48, oneSecondPass:48, oneSecondBlock:0, oneSecondBizException:24 2018-12-10 17:07:09, oneSecondTotal:48, oneSecondPass:48, oneSecondBlock:0, oneSecondBizException:24 2018-12-10 17:07:10, oneSecondTotal:47, oneSecondPass:47, oneSecondBlock:0, oneSecondBizException:24 2018-12-10 17:07:11, oneSecondTotal:49, oneSecondPass:49, oneSecondBlock:0, oneSecondBizException:24 2018-12-10 17:07:12, oneSecondTotal:48, oneSecondPass:48, oneSecondBlock:0, oneSecondBizException:24 2018-12-10 17:07:13, oneSecondTotal:48, oneSecondPass:48, oneSecondBlock:0, oneSecondBizException:24 2018-12-10 17:07:14, oneSecondTotal:48, oneSecondPass:48, oneSecondBlock:0, oneSecondBizException:24 2018-12-10 17:07:15, oneSecondTotal:49, oneSecondPass:49, oneSecondBlock:0, oneSecondBizException:25 2018-12-10 17:07:16, oneSecondTotal:48, oneSecondPass:48, oneSecondBlock:0, oneSecondBizException:24 2018-12-10 17:07:17, oneSecondTotal:48, oneSecondPass:48, oneSecondBlock:0, oneSecondBizException:24 2018-12-10 17:07:18, oneSecondTotal:49, oneSecondPass:49, oneSecondBlock:0, oneSecondBizException:24 2018-12-10 17:07:19, oneSecondTotal:48, oneSecondPass:48, oneSecondBlock:0, oneSecondBizException:24 2018-12-10 17:07:20, oneSecondTotal:49, oneSecondPass:49, oneSecondBlock:0, oneSecondBizException:25 2018-12-10 17:07:21, oneSecondTotal:48, oneSecondPass:48, oneSecondBlock:0, oneSecondBizException:24 2018-12-10 17:07:22, oneSecondTotal:48, oneSecondPass:48, oneSecondBlock:0, oneSecondBizException:24 2018-12-10 17:07:23, oneSecondTotal:49, oneSecondPass:49, oneSecondBlock:0, oneSecondBizException:24 2018-12-10 17:07:24, oneSecondTotal:48, oneSecondPass:48, oneSecondBlock:0, oneSecondBizException:24 2018-12-10 17:07:25, oneSecondTotal:49, oneSecondPass:49, oneSecondBlock:0, oneSecondBizException:25 2018-12-10 17:07:26, oneSecondTotal:48, oneSecondPass:48, oneSecondBlock:0, oneSecondBizException:24 2018-12-10 17:07:27, oneSecondTotal:48, oneSecondPass:48, oneSecondBlock:0, oneSecondBizException:24 2018-12-10 17:07:28, oneSecondTotal:48, oneSecondPass:48, oneSecondBlock:0, oneSecondBizException:24 2018-12-10 17:07:29, oneSecondTotal:49, oneSecondPass:49, oneSecondBlock:0, oneSecondBizException:24 2018-12-10 17:07:30, oneSecondTotal:48, oneSecondPass:48, oneSecondBlock:0, oneSecondBizException:24 2018-12-10 17:07:31, oneSecondTotal:49, oneSecondPass:49, oneSecondBlock:0, oneSecondBizException:25 2018-12-10 17:07:32, oneSecondTotal:48, oneSecondPass:48, oneSecondBlock:0, oneSecondBizException:24 2018-12-10 17:07:33, oneSecondTotal:49, oneSecondPass:49, oneSecondBlock:0, oneSecondBizException:24 2018-12-10 17:07:34, oneSecondTotal:48, oneSecondPass:48, oneSecondBlock:0, oneSecondBizException:24 2018-12-10 17:07:35, oneSecondTotal:49, oneSecondPass:49, oneSecondBlock:0, oneSecondBizException:25 2018-12-10 17:07:36, oneSecondTotal:48, oneSecondPass:30, oneSecondBlock:18, oneSecondBizException:15 2018-12-10 17:07:37, oneSecondTotal:49, oneSecondPass:0, oneSecondBlock:49, oneSecondBizException:0 2018-12-10 17:07:38, oneSecondTotal:48, oneSecondPass:0, oneSecondBlock:48, oneSecondBizException:0 2018-12-10 17:07:39, oneSecondTotal:49, oneSecondPass:0, oneSecondBlock:49, oneSecondBizException:0 2018-12-10 17:07:40, oneSecondTotal:48, oneSecondPass:0, oneSecondBlock:48, oneSecondBizException:0 耗時:101110 ms 總計數:4862, 經過數:3200, 降級數:1662, 業務異常數:1600 統計結束!

相關文章
相關標籤/搜索