Small D Class - New versions of Advanced Micro Services springcloud + _5-06 length of Docker-depth tutorial source code

notes

6, senior space of in-depth source code analysis Hystrix downgrade policies and adjust
    Profile: source code analysis Hystrix downgrade policies and adjustment

    1, the default view to explain the policy HystrixCommandProperties
        1) execution.isolation.strategy isolation strategy
            THREAD thread pool isolation (default)
            SEMAPHORE Semaphore
                Semaphore interfaces for high concurrency situations, as in the case of thousands of calls per second, resulting in high overhead of thread, usually only apply to non-network calls, execution speed

        2) execution.isolation.thread.timeoutInMilliseconds timeout
            default 1000 ms

        3) execution.timeout.enabled whether to open the timeout limit (must not be disabled)


        4) execution.isolation.semaphore.maxConcurrentRequests isolation policy for semaphore time, if the maximum number of concurrent, subsequent requests will be rejected, the default is 10


    The official document:
        https://github.com/Netflix/Hystrix/wiki/Configuration#execution.isolation.strategy

    2, adjust strategies
        timeout adjustment

    hystrix:
      command:
        default:
          execution:
            isolation:
              thread:
                timeoutInMilliseconds: 4000
 

Start

Analog Goods slow response. sleep2 seconds


orderService calls Goods Services
Services start correctly timed out why it? ? ? This is because feign default timeout mechanism

hystrix which itself has a fuse downgrade. Here the readTimeout set to four seconds

recall, the same problems will still

rely on set feign timeout does not work, because we use the fuse. We need to analyze hyxtrix-out strategy.
Point into @HystrixCommand this comment



after clicking on the left there is a corresponding list

to find HystrixCommandProperties

default configuration notes

constructor there are a lot of configuration items. Here we refer to the official documentation
https://github.com/Netflix/Hystrix/wiki/Configuration#execution.isolation.strategy
execution.isolation.strategy: isolation strategy


look Here is the official document,: https: //github.com / Netflix / Hystrix / wiki
a service call other related services

if one day I serve particularly slow, then all requests are piled to here

tomcat is the thread pool, all the threads are in the main card here, into other requests Not coming. Cause the entire system unusable

one thousand thread pool did not evenly distributed requests 250, when there is a request card service of the Lord can only call 250 threads. Other threads can also be used. In this card does not have a service there, so is the thread pool isolation.

Back HystrixCommandProperties


default policy points into: Default_executionIsolationsStrategy




default policy is the thread.

A semaphore is a thread

overtime time

execution.timeout.enabled 
search keyword

corresponding value here. The default is 1000 milliseconds, or 1 second.


Are execution.timeout.enabled open timeout limit (must not be disabled)
any service must not turn off the timeout, be sure to set a timeout period.
It is enabled by default. Any time a service must have the problem, certainly not unlimited links. Links will be depleted

execution.isolation.semaphore.maxConcurrentRequests isolation strategy for the semaphore time, if the maximum number of concurrent, subsequent requests will be rejected, the default is 10

which the official has a corresponding document search keywords

Set up

Which may be the entrance class, add property annotation on CommandProperties disposed inside. But so unfriendly setting. Here goes this way,

We use profiles to set up, in order to solve the problem just call timeout
There are several ways you can just close the first timeout

configured here, no tips, notes written in the past can be a direct copy of the




call again, overtime time has been closed, so there is no problem.

Another way - modified timeout


Timeout to 4 seconds

test

request takes more than 2 seconds

 

Guess you like

Origin www.cnblogs.com/wangjunwei/p/11449501.html