1、 feign中http client
如果不做特殊配置,OpenFeign默认使用jdk自带的HttpURLConnection,我们知道HttpURLConnection没有连接池、性能和效率比较低,如果采用默认,很可能会遇到性能问题导致系统故障。
可以采用Apache HttpClient,properties文件中增加下面配置:
feign.httpclient.enabled=true
pom文件中增加依赖:
<dependency>
<groupId>io.github.openfeign</groupId>
<artifactId>feign-httpclient</artifactId>
<version>9.3.1</version>
</dependency>
也可以采用OkHttpClient,properties文件中增加下面配置:
feign.okhttp.enabled=true
pom文件中增加依赖:
<dependency>
<groupId>io.github.openfeign</groupId>
<artifactId>feign-okhttp</artifactId>
<version>10.2.0</version>
</dependency>
1.2 ribbon中的Http Client
如果通过OpenFeign作为注册中心的客户端时,默认使用Ribbon做负载均衡,Ribbon默认也是用jdk自带的HttpURLConnection,需要给Ribbon也设置一个Http client,比如使用okhttp,在properties文件中增加下面配置:
ribbon.okhttp.enabled=true
参考如下:
https://andyoung.blog.csdn.net/article/details/121133989