当前位置:网站首页>Use of feign (Part 2)
Use of feign (Part 2)
2022-07-26 05:35:00 【Hua Weiyun】
🧁Java Code configuration
It can also be based on Java Code to modify the log level , Foretell a class , Then declare a Logger.Level The object of :
public class DefaultFeignConfiguration { @Bean public Logger.Level feignLogLevel(){ return Logger.Level.BASIC; // Log level is BASIC }}If you want to Global effect , Put it in the... Of the startup class @EnableFeignClients In this note :
@EnableFeignClients(defaultConfiguration = DefaultFeignConfiguration .class) If it is Partial effect , Then put it in the corresponding @FeignClient In this note :
@FeignClient(value = "userservice", configuration = DefaultFeignConfiguration .class) Feign Tuning of
Feign Performance tuning book ⾝ Very good performance ⾼, But you can still optimize .
feign The underlying client implementation :
URLConnection: Default implementation , Connection pooling is not supported
Apche HttpClient: Support connection pool
OKHttp: Support connection pool
So optimize feign The performance of
Use the connection pool instead of the default connection pool URLConnection
The level of logging : meanwhile ⽇ The level of ambition is different , The performance consumed is also different , Use as much as possible Basic Level or none
You can make ⽤Apche HttpClient or OKHttp Into the ⾏ Optimize
Feign Bottom layer initiation http request , Rely on other frameworks . Its underlying client implementation includes :
•URLConnection: Default implementation , Connection pooling is not supported
•Apache HttpClient : Support connection pool
•OKHttp: Support connection pool
So improve Feign The main means of performance is to use Connection pool Instead of default URLConnection.
Here we use Apache Of HttpClient To demonstrate .
First step Introduce dependencies
stay order-service Of pom Introduce in the file Apache Of HttpClient rely on :
<!--httpClient Dependence --><dependency> <groupId>io.github.openfeign</groupId> <artifactId>feign-httpclient</artifactId></dependency>2) Configure connection pool
stay order-service Of application.yml Add configuration in :
feign: client: config: default: # default Global configuration loggerLevel: BASIC # The level of logging ,BASIC Is the basic request and response information httpclient: enabled: true # Turn on feign Yes HttpClient Support for max-connections: 200 # Maximum number of connections max-connections-per-route: 50 # Maximum number of connections per path stay FeignClientFactoryBean Medium loadBalance Break in the method , and Debug Mode start order-service service , The bottom is Apache HttpClient.
1. Try to use the log level basic
2. Use HttpClient or OKHttp Instead of URLConnection
① introduce feign-httpClient rely on
② Profile on httpClient function , Set connection pool parameters

This is the end of the article , If you have any questions, please point out
Thank you again for your support 
边栏推荐
猜你喜欢

FPGA刷题——序列检测

FPGA question brushing sequence detection

Attack and defense world flatscience

Common modules in ansible

Application of canoe XML in test modules

TZC 1283: simple sort Bubble Sort

Day011 一维数组

517. Super washing machine

Redis official visualization tool, with high appearance value and powerful functions!

Another open source artifact, worth collecting and learning!
随机推荐
【个人总结】2022.7.24周结
MongoDB 常用命令
攻防世界--easy_web
Dynamic memory management and flexible array
517. 超级洗衣机
调试利器!一款轻量级日志库 log.c
我又发现了超赞的软硬件项目,全部开源
Development projects get twice the result with half the effort, a large collection of open source STM32 driver Libraries
LNMP architecture
Okaleido launched the fusion mining mode, which is the only way for Oka to verify the current output
Okaleido上线聚变Mining模式,OKA通证当下产出的唯一方式
ES Cluster in Red status: what about write & delete operations?
Jupiter notebook shortcut key
LAMP架构
Benji Bananas 开启第二季边玩边赚奖励活动,支持使用多张 Benji 通行证!
MongonDB API使用
Hack the box - Web requests module detailed Chinese tutorial
520送什么?DIY一个高颜值RGB时钟,女生看了都想要
攻防世界-FlatScience
How students apply for free idea