(Forty-four) java version of spring cloud micro Services Architecture b2b2c e-commerce platform -hystrix resource isolation technology

hystrix in fact, the core feature is a resource isolation, is to rely on multiple service calls were isolated to individual internal resources, avoid the reliance failure or delay services, leading to service all of the resources spent in this thread damage, then lead to the collapse of service.

Thread pool semaphore isolation and isolation

hystrix There are two main technical resource isolation: isolation and thread pool semaphore isolation.

scenes to be used:

Thread pool isolation technology: In most of the scenes are actually suitable for this technique, dependence on service calls and access; solve the timeout scene scene, avoid calling thread to block live.

Semaphore isolation technology:

Usually the scene for a large amount of concurrency, QPS each service instance are very high, if the thread pool, you may barely so high concurrency, if you want to shore, you may want to spend a lot of thread resources, then it is a signal the amount to be limiting protection.

That is for you to access does not depend on external services, but only some of the complex business logic inside access, because he is internal access, there is no question timeout for more complex business logic code to prevent a large number of these thread logic stuck to the stability of the system.

the difference:

Thread pool isolation technology, not to control the web container threads, but the use of thread pool isolation technology, control of the implementation of web container threads, rather than the web threads of the container itself.

And semaphore isolation What difference does it make? For example, a capacity for the number of threads and semaphores pool of 20, in fact, is the thread pool thread to call with their own web container, and semaphore isolation is a direct thread to call directly to the web container dependent services; the former will throw abnormal, execution thread web container can be captured, and then do further processing. The latter is a direct return.

Resources related concepts isolated

For each command, in fact, you can set their own names, and set their own grouping command group.

command group: a very important concept, by default, is defined by a command group of the thread pool, but also to some of the polymerization and alarm information through the monitoring command group; the same request in a command group, will enter the same thread pool.

command thread pool

threadpool key represents a HystrixThreadPool, for unified monitoring, statistics, caching; the default threadpool key is the command group name; each command will be saying the threadpool key corresponding threadpool bound together, if not by direct command group, threadpool name can also be set manually.

command threadpool VS command group VS command key

command key: Command represent a class, in general, dependent on the underlying abstraction into one of the interfaces and services.

command group: represents one underlying dependency service, a service may be exposed depend on multiple interfaces, each interface is a command key; the logical command key up to organize a bunch of calls, statistics, the number of successes, timeout timeouts, the number of failures, you can see some of the visits a particular service overall

command threadpool: In general, the recommendation is based on a service division to a thread pool, command key default they belong to the same thread pool.

In general, command group is corresponding to a service, a plurality of a plurality of interfaces to the service command key, a plurality of call interfaces share the same thread pool; follows:
Isolation .jpg

Of course, if commandkey need their own thread pool, but also you can customize.

coreSize

Set the thread pool size, the default is 10

queueSizeRejectionThreshold

Control queue after reject full capacity, maxQueueSize not allowed to modify the heat, so the heat can be modified to provide this parameter to control the maximum size of the queue; HystrixCommand prior to submission to the thread pool, after the fact, will first enter a queue, the queue is full, will reject. In fact, with this mechanism works before talking about the thread pool is very similar.

execution.isolation.semaphore.maxConcurrentRequests:

Set when using SEMAPHORE isolation policies, the maximum allowable amount of concurrent access, to exceed the maximum amount of concurrent requests directly reject

Guess you like

Origin blog.csdn.net/vvx0206/article/details/95165188