SpringCloud Alibaba - Performance Optimization of Feign

1. Performance optimization of Feign

  • The bottom layer of Feign defaults to the HttpURLConnection that comes with JDK. It sends HTTP requests with a single thread and cannot configure a thread pool. We use Okhttp or HttpClient to send http requests, and both of them support thread pools.

2. Common HTTP clients

2.1、HttpClient

  • HttpClient is a sub-project under Apache Jakarta Common , which is used to provide an efficient, up-to-date, feature-rich client programming toolkit supporting the Http protocol , and it supports the latest version and recommendations of the HTTP protocol . Compared with the URLConnection that comes with the traditional JDK, HttpClient improves the usability and flexibility, makes it easier for the client to send HTTP requests, and improves the efficiency of development.

2.2、okhttp

  • An open source project for processing network requests, is the most popular lightweight framework on the Android side, contributed by Square, used to replace HttpUrlConnection and Apache HttpClient . OkHttp has a concise APl, efficient performance, and supports multiple protocols (HTTP/2 and SPDY).

2.3、HttpURLConnection

  • HttpURLConnection is a standard Java class, which inherits from URLConnection, and can be used to send GET requests and POST requests to specified websites . HttpURLConnection is more complicated to use, not as easy to use as HttpClient.

2.4、RestTemplate

  • RestTemplate is a client provided by Spring for accessing Rest services. RestTemplate provides a variety of convenient methods for accessing remote HTTP services, which can greatly improve the writing efficiency of clients.

Guess you like

Origin blog.csdn.net/li1325169021/article/details/131756568
Recommended