网站开发文献综述范文,网店装修网站,唐山网站制作企业,手机网站变灰hystrix隔离策略
zuul的隔离实现是基于hystrix实现的#xff0c;hystrix支持线程池隔离和信号量的隔离
# 信号量隔离#xff1a;
it executes on the calling thread and concurrent requests are limited by the semaphore count --引自官网单每次调用线程#xff0c;当…hystrix隔离策略
zuul的隔离实现是基于hystrix实现的hystrix支持线程池隔离和信号量的隔离
# 信号量隔离
it executes on the calling thread and concurrent requests are limited by the semaphore count --引自官网单每次调用线程当前请求通过技术信号量进行限制当信号量大于了最大请求数maxConcurrentRequest时候触发限制调用fallback接口快速返回。 此处可能出现的问题在于信号量的调用是同步的也就是说每次调用都会阻塞调用方的线程一直到结果返回这样就导致了无法对访问做超时只能依靠调用协议超时无法主动释放
官网对信号量隔离的描述 Generally the only time you should use semaphore isolation for HystrixCommands is when the call is so high volume (hundreds per second, per instance) that the overhead of separate threads is too high; this typically only applies to non-network calls. 两点 隔离的粒度太细数百个实例需要隔离此时用线程池做隔离开销过大通常这种都是非网络调用的情况下
# 线程池隔离
it executes on a separate thread and concurrent requests are limited by the number of threads in the thread-pool -引自官网
通过每次都开启一个单独线程运行他的隔离是通过线程池即每个隔离粒度都是线程池互不干扰。
Commands executed in threads have an extra layer of protection against latencies beyond what network timeouts can offer.
线程池隔离方式等于多了一层保护措施可以通过hystryx直接设置超时时间超时后直接返回 对比表格‘
隔离方式是否支持超时是否支持熔断隔离原理是否异步调用资源消耗线程池隔离支持可以直接返回支持当线程池达到maxsize后再请求会出发fallback熔断每个服务单独用线程池可以是异步也可以是同步。看调用的方法消耗大大量线程的上下文切花容易造成机器负载过高信号量隔离不支持如果阻塞只能通过调用协议比如socket超时返回支持当信号量达到maxConcurrentRequests后再请求会触发fallback熔断通过信号量计数器同步调用不支持异步消耗小只是一个计数器
zuul网关如果使用线程池隔离是属于异步调用其实查看源码如下 调用的是hystrix command 的excute方法hytrix的官网原文说明如下
execute() — blocks, then returns the single response received from the dependency (or throws an exception in case of an error)
execute是一个阻塞方法也就是说如果不合理的设置线程池的大小和超时时间还是有可能把zuul的线程消耗完。从而失去对服务的保护作用