Springcloud about @feignclient and Hystrix integration to the HTTP thread pool monitoring issues

Source: Internet
Author: User

@FeignClient can be used as an HTTP proxy to access other microservices nodes, you can replace the @feignclient native URLConnection request mode with Apache HttpClient to allow HTTP requests to go to the HTTP thread pool. With the integration of @feignclient and Hystrix, the Hystrix dashboard can monitor the interface invocation situation in @feignclient and @feignclient the usage of the thread pool.

Here is an example of demo:

1, @FeignClient Interface code is as follows:

@FeignClient (value= "service-a", Fallback=serviceclienthystrix.class)
Public interface ServiceClient {

@RequestMapping (method = requestmethod.get, value = "/add/{id}")
String Add (@PathVariable ("id") Integer ID);

}

2, Serviceclienthystrix.java

@Component
public class Serviceclienthystrix implements serviceclient{
@Override
Public String Add (Integer ID) {
Return "add value from Serviceclienthystrix";
}

}

3. With regard to @feignclient and hystrix integration, the HTTP thread pool is configured as follows:

Hystrix.threadpool. Service instance ID. Parameters

For example, set the thread pool maximum number of threads for httpclient

hystrix.threadpool.service-a.coresize=20//default is Hystrix.threadpool.default.coreSize = 10
hystrix.threadpool.service-a.maximumsize=20//default is Hystrix.threadpool.default.maximumSize = 10

After starting the service, we use the test case to call the interface test continuously, using Hystrix Dashboard Monitor to get the following image monitoring effect:


Remove Hystrix.threadpool. Service Instance ID. Once the parameter is configured, it is monitored again with the test case call interface as shown below:


The size of the poolsize depends on the Hystrix.threadpool. Service instance id.coresize size setting


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.