SpringCloud进阶–Zuul与Ribbon的Timeout配置

文章内索引
[显示]

SpringCloud进阶–Zuul与Ribbon的Timeout配置

  1. Springcloud第一次请求超时

    当通过zuul第一次请求微服务中的服务时,由于也是通过ribbon的http请求去请求原子服务,第一次请求需要加载一些路由基本信息,会报SocketTimeoutException: Read timed out超时错误。

,查看源码AbstractLoadBalancingClient发现可以通过

,设置超时时间,其中ConnectTimeout代表建立stocket连接的超时时间,readtimeout为连接建立后,服务返回值的超时时间。

 

  1. Hystrix小于ribbon超时时间

我的hystrix的超时时间是设置60000,发现会提示

The Hystrix timeout of 60000ms for the command HJ-RiskRule-Edge is set lower than the combination of the Ribbon read and connect timeout, 180000ms.

通过源码发现,原来ribbon中的超时时间算法是,其中maxAutoRetries 是每台服务器最多重试次数,但是首次调用不包括在内,maxAutoRetriesNextServer是最多重试多少台服务器。

ribbonTimeout = (ribbonReadTimeout + ribbonConnectTimeout) * (maxAutoRetries + 1) * (maxAutoRetriesNextServer + 1);

通过以上设置,第一次请求时,已经不会再报超时错误。


©版权声明:本文为【翰林小院】(huhanlin.com)原创文章,转载时请注明出处!

2 评论

  1. Julius Keys说道:

    Need to find powerful online marketing that isn’t full of crap? Sorry to bug you on your contact form but actually that’s exactly where I wanted to make my point. We can send your advertising message to websites through their contact pages just like you’re reading this note right now. You can target by keyword or just go with mass blasts to websites in the country of your choice. So let’s assume you would like to send an ad to all the web developers in the United States, we’ll grab websites for only those and post your advertisement to them. Providing you’re promoting something that’s relevant to that niche then you’ll be blessed with awesome results!

    Send a quick note to sarah1916eva@gmail.com to get details about how we do this

  2. Torri Klug说道:

    Are you looking for effective online promotion that actually gets good results? Sorry to bug you on your contact form but actually that was the whole point. We can send your promotional message to sites through their contact forms just like you’re getting this message right now. You can target by keyword or just fire off mass blasts to websites in the country of your choice. So let’s assume you’re looking to blast a message to all the plumbing companies in the USA, we’ll grab websites for only those and post your promo to them. As long as you’re promoting something that’s relevant to that business category then you’ll receive an amazing response!

    Write a quickie email to mark3545tho@gmail.com to find out how we do this

发表评论

电子邮件地址不会被公开。