天天看點

Spring Boot中使用Feign調用時Hystrix提示異常Spring Boot中使用Feign調用時Hystrix提示異常:"could not be queued for execution and no fallback available."以及"Rejected command because thread-pool queueSize is at rejection threshold"

Spring Boot中使用Feign調用時Hystrix提示異常:"could not be queued for execution and no fallback available."以及"Rejected command because thread-pool queueSize is at rejection threshold"

說明:

1、我還沒有真正了解Spring Cloud的精髓,現隻停留在使用階段,可能存在分析不到位的問題。

1、這個是由于線程池的最大數量導緻的,官方說随着線程池的數量越大,資源開銷也就越大,是以調整時要慎重。

2、Hystrix預設是10個線程,超過就會報這個異常。

解決方法:

hystrix:
  threadpool:
    default:
      coreSize: 200 ##并發執行的最大線程數,預設10
      maxQueueSize: 200 ##BlockingQueue的最大隊列數
      queueSizeRejectionThreshold: 50 ##即使maxQueueSize沒有達到,達到queueSizeRejectionThreshold該值後,請求也會被拒絕
    default:
      execution:
        timeout:
          enabled: true
        isolation:
          strategy: THREAD
          semaphore:
            maxConcurrentRequests: 1000
          thread:
            timeoutInMilliseconds: 30000
           

說明:以上是YAML寫法

參考:

http://blog.csdn.net/gisam/article/details/78028080

http://blog.csdn.net/u011742484/article/details/59524361

http://blog.csdn.net/chenpeng19910926/article/details/78295720?locationNum=2&fps=1

http://blog.csdn.net/w_x_z_/article/details/72222550

http://ju.outofmemory.cn/entry/68192

https://segmentfault.com/a/1190000009939815

http://tietang.wang/2016/02/25/hystrix/Hystrix%E5%8F%82%E6%95%B0%E8%AF%A6%E8%A7%A3/

https://github.com/Netflix/Hystrix/issues/1428

https://github.com/Netflix/Hystrix/wiki/Configuration#allowmaximumsizetodivergefromcoresize

繼續閱讀