From 84bbe0b59745081b3fd3f30223a68b8365b242c9 Mon Sep 17 00:00:00 2001 From: yanglbme Date: Tue, 14 May 2019 15:15:46 +0800 Subject: [PATCH] docs(high-availability): update hystrix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 更新 Hystrix 多个文件描述信息 --- docs/high-availability/hystrix-fallback.md | 1 + docs/high-availability/hystrix-process.md | 9 +++++---- .../hystrix-thread-pool-current-limiting.md | 4 ++-- docs/high-availability/hystrix-thread-pool-isolation.md | 1 - 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/docs/high-availability/hystrix-fallback.md b/docs/high-availability/hystrix-fallback.md index a47b08a..cb9e06c 100644 --- a/docs/high-availability/hystrix-fallback.md +++ b/docs/high-availability/hystrix-fallback.md @@ -42,6 +42,7 @@ public class BrandCache { /** * brandId 获取 brandName + * * @param brandId 品牌id * @return 品牌名 */ diff --git a/docs/high-availability/hystrix-process.md b/docs/high-availability/hystrix-process.md index dbd6d89..0f2f0e4 100644 --- a/docs/high-availability/hystrix-process.md +++ b/docs/high-availability/hystrix-process.md @@ -40,9 +40,9 @@ HystrixObservableCommand hystrixObservableCommand = new HystrixObservableCommand - toObservable():返回一个 Observable 对象,如果我们订阅这个对象,就会执行 command 并且获取返回结果。 ```java -K value = hystrixCommand.execute(); -Future fValue = hystrixCommand.queue(); -Observable oValue = hystrixObservableCommand.observe(); +K value = hystrixCommand.execute(); +Future fValue = hystrixCommand.queue(); +Observable oValue = hystrixObservableCommand.observe(); Observable toOValue = hystrixObservableCommand.toObservable(); ``` @@ -106,7 +106,8 @@ observable.subscribe(new Observer() { /** * 获取完一条数据,就回调一次这个方法 - * @param productInfo + * + * @param productInfo 商品信息 */ @Override public void onNext(ProductInfo productInfo) { diff --git a/docs/high-availability/hystrix-thread-pool-current-limiting.md b/docs/high-availability/hystrix-thread-pool-current-limiting.md index 965dc37..4614f0a 100644 --- a/docs/high-availability/hystrix-thread-pool-current-limiting.md +++ b/docs/high-availability/hystrix-thread-pool-current-limiting.md @@ -58,8 +58,8 @@ semaphore 技术可以用来限流和削峰,但是不能用来对调研延迟 在 command 内部,写死代码,做一个 sleep,比如 sleep 3s。 -- withCoreSize:设置线程池大小 -- withMaxQueueSize:设置等待队列大小 +- withCoreSize:设置线程池大小。 +- withMaxQueueSize:设置等待队列大小。 - withQueueSizeRejectionThreshold:这个与 withMaxQueueSize 配合使用,等待队列的大小,取得是这两个参数的较小值。 如果只设置了线程池大小,另外两个 queue 相关参数没有设置的话,等待队列是处于关闭的状态。 diff --git a/docs/high-availability/hystrix-thread-pool-isolation.md b/docs/high-availability/hystrix-thread-pool-isolation.md index 6a84d16..fc5a75e 100644 --- a/docs/high-availability/hystrix-thread-pool-isolation.md +++ b/docs/high-availability/hystrix-thread-pool-isolation.md @@ -1,5 +1,4 @@ ## 基于 Hystrix 线程池技术实现资源隔离 - 上一讲提到,如果从 Nginx 开始,缓存都失效了,Nginx 会直接通过缓存服务调用商品服务获取最新商品数据(我们基于电商项目做个讨论),有可能出现调用延时而把缓存服务资源耗尽的情况。这里,我们就来说说,怎么通过 Hystrix 线程池技术实现资源隔离。 资源隔离,就是说,你如果要把对某一个依赖服务的所有调用请求,全部隔离在同一份资源池内,不会去用其它资源了,这就叫资源隔离。哪怕对这个依赖服务,比如说商品服务,现在同时发起的调用量已经到了 1000,但是线程池内就 10 个线程,最多就只会用这 10 个线程去执行,不会说,对商品服务的请求,因为接口调用延时,将 tomcat 内部所有的线程资源全部耗尽。