hystrix断路器示例二
<h1>场景描述</h1>
<pre><code>断路器核心线程数设置20个,压测线程数为100个,则大多数请求发生断路。</code></pre>
<h1>演示步骤</h1>
<h2>第一步:在压测工具jmeter上配置100个线程,每个线程循环100次。</h2>
<p><img src="https://www.showdoc.cc/server/api/common/visitfile/sign/56a6fae0c623370e74ea7e0757e66d4a?showdoc=.jpg" alt="" />
运行程序,可以看到很多请求走了断路通道,并且所有请求在3秒内运行完毕,而之前没有断路时这10000个请求需要10秒左右才能处理完毕。
<img src="https://www.showdoc.cc/server/api/common/visitfile/sign/f089299919c124b19efa2f898f7c7352?showdoc=.jpg" alt="" />
断路通道的配置代码如下
<img src="https://www.showdoc.cc/server/api/common/visitfile/sign/69c49eb9d46d0d9155c171b5eb033bef?showdoc=.jpg" alt="" /></p>
<h2>第二步:到数据库确定结果</h2>
<p><img src="https://www.showdoc.cc/server/api/common/visitfile/sign/28abc62e9c0feb7b5308cbbbb26b9d92?showdoc=.jpg" alt="" />
可以看到,10000次请求,只有不到2000次请求成功。</p>