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)原创文章,转载时请注明出处!

3 评论

  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

  3. de Bakker说道:

    Hey

    I wanted to invite you to our webinar today.

    To confirm your seat, for the Live webinar from Carol Bell & Michel de Bakker for today 11:00 AM in Eastern Time (US and Canada), sent us an email to confirmlivewebinarseat@gmail.com

    Here’s a quick Overview of what we’re going to cover:
    • 5 Expensive Marketing Mistakes many business owners make, that prevent them from getting the results they want and how to avoid them (we’ll show you what’s working now)
    • How to know where to start and what to focus on
    • How to put together a cohesive marketing plan and stop wasting time on tasks that have no value
    • How to know if you are targeting the wrong keywords…
    • How to know if you are missing one of the most important components of your marketing … Learning this can dramatically lead to more sales…
    • And much MUCH more…

    Yours truly
    Michel de Bakker & Carol Bell

    “Sent from my iPhone”

发表评论

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